[ZODB-Dev] bsddb3 mass creation problem.

Michel Pelletier michel@digicool.com
Thu, 17 May 2001 13:47:38 -0700 (PDT)


On Thu, 17 May 2001, Christian Robottom Reis wrote:

>
> Hi,
>
> I'm getting the following error when creating 10,000 objects in a bsddb3
> storage. I haven't had a chance to look at the code yet, but if somebody
> has seen this before..
>
> My creation loop is as follows:
>
>     for f in range(0,10000):
>         foo = a.createModel("Foo")
>         foo_at = a.createAttributeType("FooAType","An Attribute Type for
> Foo")
>         foo.addAttributeType(foo_at)
>         get_transaction().commit(1)
>     get_transaction().commit()
>

I don't know the solution to your problem, but I do know that calling
commit(1) every time you add an object is not more efficient than calling
commit() every time.  You should call commit(1) after every N objects are
added, N being probably on the order of at least a hundred (depending on
your objects).  just change the second to last line to:

if not f % N: get_transaction.commit(1)

(don't forget to assign N)

-Michel