On Oct 15, 2007, at 4:34 PM, pbienst wrote:

>
> I wrote:
>
>> My database state should be OK if I don't get an error?
>
> More specifically I mean the following. If I do:
>
> -create A
> -save A
> -flush
>
> -create B
> -save B
>
> If I now do a query asking for the last item in the database, would I
> get A or B? If I get A, I need to flush all the time, and then I'm
> back to the 18 sec version.
>

if you are inserting "card" items, and your parse process requires  
that it get the most recent "card" item to associate with the current  
row, I wouldnt even query for that, I'd just store the most recently  
saved "card" item in a local variable somewhere.   otherwise, if you  
need the database state to be current in order to continue parsing,  
yes you'd need to issue a flush after each save(), although you can  
further reduce the overhead of those flushes by passing in the  
specific objects to be flushed, i.e. session.flush([B]).

if you can organize your program to just hold onto the most recently  
saved dependent item, you might not even have to flush anything until  
the very end (which is usually how people do these things, flushing  
only at the very end or after every batch of N objects to  
compartmentalize the size of the session).

the other approach you could take with this application if speed is  
very important is to not use ORM and to use direct table.insert()  
statements, and to use table.select() to get at recently inserted  
rows.  this is also a typical method used for large sets of tabular  
data (i.e. the answer to the original question is yes, the  
abstraction of the ORM does add a lot of overhead to pretty much all  
operations).





--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to