1
votes

In C on an embedded system (where memory is an issue), trying to optimize performance, multiple inserts are combined into larger transactions.

Intuitively, SQLITE must keep the unsent transactions in a cache somewhere in the limited memory.

  • Is it possible to have too many inserts between two calls of 'BEGIN TRANSACTION' and 'END TRANSACTION'? Can the cache overflow?
  • Or, does sqlite3 take care of it and initiate a transaction before a overflow happens?
  • If the cache may overflow, what is the best strategy to call BEGIN/END?
1

1 Answers

2
votes

Any changes you make are written to the database file. To support rollbacks, the old contents of the changed database pages are saved in the journal file. When you commit a transaction, the journal file is just deleted; when you roll back a transaction, those pages are written back.

So there is not limit on the size of the data in a transaction, as long as you have enough disk space.

(The cache can help with avoiding some writes, but it works transparently and does not affect the semantics of your code.)