[odb-users] performance of updates in table with many rows for sqlite db

Boris Kolpackov boris at codesynthesis.com
Wed Sep 19 10:33:54 EDT 2012


Hi Daniel,

Daniel James <danielpeterjames at gmail.com> writes:

> How can I ensure the db _is_ in autocommit mode? Simply being outside
> a transaction does not seem to be enough. I'm only accessing the db
> with a single thread, is it possible that ODB is keeping the
> transaction open beyond than the transaction::commit() call?

You need to turn the foreign key checking off before the transaction
starts and turn it back on after it has finished:

odb::connection_ptr c (db->connection ());
c->execute ("PRAGMA foreign_keys=OFF;");

transaction t (c->begin ()); // Note: not db->begin ()!

...

t.commit ();

c->execute ("PRAGMA foreign_keys=ON;");

Boris



More information about the odb-users mailing list