26MB is the size of the "pickle" produced for the entire PersistentMapping
object. As the message says, PersistentMapping
isn't scalable: if you add one more key-value pair to it, and commit the transaction, it will write out that 26MB (plus the size of the single new pair you added) again. Every time you change your PersistentMapping
instance and commit, the entire object is stored to disk (including all the objects you added before). Over a series of additions and commits, this yields a total database size quadratic in the number of items you've added, and also suffers quadratic time behavior (each new item you add takes longer than the last one added, because each commit writes out all previously added items too, not just the last item added).
Look in the docs for the various flavors of BTree
ZODB supports. Those are scalable, persistent key-value mappings, and are almost certainly what you should be using for this task.
Note that ZODB implements several flavors of BTree
for efficiency. Most general is the OOBTree
, which allows general objects for both keys and values. Most specific is the IIBTree
, which allows only 32-bit integers for keys and for values. Here's a tutorial: