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.
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.
