SiaqoDB Performance - Huge difference between the time taken with and without "Transaction"

105 views
Skip to first unread message

suba...@gmail.com

unread,
Jul 20, 2016, 9:42:37 AM7/20/16
to Siaqodb - NoSQL embedded database for .NET

System Configuration:
Intel® Core™, i7-4702MQ CPU @2.20GHz 2.20 GHz , 16GB RAM, 64-bit, Windows 7

public class Employee : ISqoDataObject
    {
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public DateTime HireDate { get; set; }
        public int Age { get; set; }
        public int Sno { get; set; }
        private int oid;
        public int OID
        {
            get { return oid; }
            set { oid = value; }
        }
    }

private Siaqodb _myDb = new Siaqodb(siaoqodbPath);

Insert : 
            stopwatch.Start();
            for (int i = 0; i < count; i++)
            {
                Employee emp = CreateRandomEmployee();
                _myDb.StoreObject(emp);
            }

            stopwatch.Stop();
            log.Info("TimeElapsed=" + stopwatch.Elapsed);

Insert with Transaction:

            var transaction = _myDb.BeginTransaction();
             stopwatch.Start();
            for (int i = 0; i < count; i++)
            {
                Employee emp = CreateRandomEmployee();
                _myDb.StoreObject(emp, transaction);
            }
            transaction.Commit();
            stopwatch.Stop();
            log.Info("TimeElapsed=" + stopwatch.Elapsed);

Update:
   
         stopwatch.Start();
           foreach (Employee emp in list)
           {
              emp.Age = emp.Age % 30;
               _myDb.StoreObject(emp);
          }
          stopwatch.Stop();
          log.Info("TimeElapsed=" + stopwatch.Elapsed);

Update with Transaction:
      
             var transaction = _myDb.BeginTransaction();
             stopwatch.Start();
             foreach (Employee emp in list)
             {
                emp.Age = emp.Age % 30;
                _myDb.StoreObject(emp, transaction);
             }
            transaction.Commit();
            stopwatch.Stop();
            log.Info("TimeElapsed=" + stopwatch.Elapsed);


Based on the below data the time taken was very less for "transaction" .

For example insert 1000 objects with and without "Transaction" 0.21 second and  51.82 second respectively. The same for update and Delete also.

The column Siaqo with green color data are taken from your site(http://siaqodb.com/siaqodb-performance/). In your sample you are not using transaction.

Why is there such a huge difference between the time taken with and without "Transaction"?

Is my code have  any issue or i have to use always transaction?. Kindly verify and suggest me.

Version : Siaqodb.5.5.0.6

Times are in Seconds.












Siaqodb Support

unread,
Jul 21, 2016, 1:57:20 AM7/21/16
to Siaqodb - NoSQL embedded database for .NET, suba...@gmail.com
hello there,
That can be normal. Siaqodb is fully transactional, it means for every operation it uses a transaction even is not visible in the client code. So when you call 

siaqodb.StoreObject(emp);

Internally it is opened a transaction, store the object, update indexes, update the metadata,etc and at the end transaction is committed.

When you use a transaction in your client code and store multiple objects in the same transaction, everything is much faster and is normal to be like that.

So we recommend you to use (client opened) transactions always when you need to store batches (multiple objects) at once to have a better performance.

Also take a look on the latest benchmark/performance test on GitHub: https://github.com/Dotissi/SiaqodbBenchmark/tree/master/Siaqodb_vs_RavenDB where we use transaction and compare Siaqodb with RavenDB, more explanations here:
Reply all
Reply to author
Forward
0 new messages