previously I had 500 operations in one transaction lasting too long, so I had to change it for 500 transactions in foreach block.
I am checking the time of making each transaction (I use Stopwatch) and I noticed that every foreach loop (every new transaction) is a bit longer than previous one. It raised from ~80 milliseconds to ~400. My code:
foreach (var single in data)
{
using (var tran = _session.BeginTransaction())
{
// operations with "single" usage - _session.Save() or _session.Update()
//...
tran.Commit();
}
}
What am I doing wrong? Should I dispose, flush something after tran.Commit()?