According to ZODB documentation:
A savepoint allows a data manager to save work to its storage without committing the full transaction." "Savepoints are also useful to free memory that would otherwise be used to keep the whole state of the transaction.
According to the very instructive article When to commit data in ZODB (Martijn Pieters):
... a point during the whole transaction where you can ask for data to be temporarily stored on disk. [...]
One thing a savepoint does, is call for a garbage collection of the ZODB caches, which means that any data not currently in use is removed from memory.
The thing is, I need to store a lot of items in one transaction, something like this:
for i, item in enumerate(aLotOfItems):
database[i]=item
if i % 10000 ==0:
transaction.savepoint(True)
transaction.commit()
I kindof expected transaction.savepoint to work the same way as bsddb3.db.Db.sync
. When Db.sync()
is called, the database is flushed and you can observe it. But when a savepoint is set, apparently neither the database nor the tmp file grows or changes in size untill transaction.commit()
.
I am really confused about:
What is actually happening when a savepoint is set?
How is it different from commiting/flushing a database?
If "data to be temporarily stored on disk", to where does the savepoint write the data?
Can I count on savepoints to literally "free memory"?