Tres Seaver wrote:
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> tsmiller wrote:
>> ZODB guys,
>> 
>> I have discovered the following.
>> 
>> db.dbRoot is the root of my database and 'accounts'  is a key.  I simply
>> want to set a timestamp for when a user logs in.  I make the timestamp
>> persistent by assigning the database key to a variable and back again as
>> in
>> the following code.
>> 
>>  accounts = db.dbRoot['accounts'][accountKey]
>>  accounts[accountKey]['last-login-time'] = int(time.time()) 
>>  db.dbRoot['accounts'][accountKey] = accounts
>>  transaction.commit()       
>> 
>> I have discovered that each time this code is executed, it increases the
>> size of my database by about 800,000 bytes.  Even though I suspect that
>> it
>> writes all of the accounts, the data in all of the accounts is not
>> anywhere
>> near 800,000.  It is about 2k. 
>> 
>> I have been googling the ZODB and need to learn.  Your answers on this
>> list
>> are pretty much over my head, but for now  could you please tell me how
>> to
>> save about 50 bytes of information without the additional 799,950?  
> 
> The simple answer is to use PersistentMappings or OOBTrees, rather than
> a set of dict objects, for your 'accounts' data structure:  those
> classes store the mapping data across multiple persistent objects, and
> only write the sub-objects which have actually changed in a transaction.
> 
> 
> Tres.
> - --
> ===================================================================
> Tres Seaver          +1 540-429-0999          [EMAIL PROTECTED]
> Palladion Software   "Excellence by Design"    http://palladion.com
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
> 
> iD8DBQFHRIDi+gerLs4ltQ4RAotkAJ9SDMDRL2wG3TRIOB720vOXlQTYmwCfT086
> 5xuaao0Iy1OYIihyPUvTXYM=
> =vwSa
> -----END PGP SIGNATURE-----
> 
> _______________________________________________
> For more information about ZODB, see the ZODB Wiki:
> http://www.zope.org/Wikis/ZODB/
> 
> ZODB-Dev mailing list  -  ZODB-Dev@zope.org
> http://mail.zope.org/mailman/listinfo/zodb-dev
> 
> 
This is what my gut feeling was telling me.  Before I knew ANYTHING about
the ZODB it seemed natural and easy to just use dictionaries as data
structures for things such as accounts, books, dialogs, etc..   But it looks
like the database saves the entire dictionary if anything in it changes.  Is
this correct and is this why I need to use the PersistentMappings or BTrees? 
Why would I use one over the other?  

Thanks for the response,

Tom
-- 
View this message in context: 
http://www.nabble.com/Database-size-increase-on-commit%28%29-tf4852044.html#a13884183
Sent from the Zope - ZODB-Dev mailing list archive at Nabble.com.

_______________________________________________
For more information about ZODB, see the ZODB Wiki:
http://www.zope.org/Wikis/ZODB/

ZODB-Dev mailing list  -  ZODB-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zodb-dev

Reply via email to