[odb-users] Commit in batch

Boris Kolpackov boris at codesynthesis.com
Wed Mar 28 05:45:49 EDT 2012


Hi Davide,

Davide Anastasia <Davide.Anastasia at qualitycapital.com> writes:

> My application is quite fast and I would to commit every (let's say)
> 1000 updates, in order to decrease DB overhead. Is there a way to
> achieve that? Unfortunately, the object odb::transaction, once
> committed, cannot be restarted again (is that correct?).

Hm, looks like having something like transaction::reset() would be
useful here:

transaction t (db.begin ());

...

t.commit ();
t.reset (db.begin ());

...

t.commit ();

I've added this to the TODO list for the next release. In the meantime
you can use this approach, which is not very elegant but essentially
equivalent:

transaction t (db.begin ());

...

t.commit ();
t.~transaction ();
new (&t) transaction (db.begin ());

...

t.commit ();

Boris



More information about the odb-users mailing list