the session doesn't save any parsed statements. whether or not you expunge everything, issuing any Query will always issue SQL back to the database, except in the case for query.get() where it can use an identity map lookup.
you can prevent any data from being written if you set autoflush=False, however if you're looking for objects to be removed from the Session as they fall out of scope, they would have to be "clean", i.e. unchanged, otherwise expunging them is the only way to go. But if they're expunged then query.get() for a certain ID will issue the SQL again. In my experience, Oracle doesn't "re-parse" the same statement twice in most cases, it uses query plan caching so when it sees the identical SQL it pulls a precompiled plan from its own internal cache and works very efficiently. This is a key rationale behind using bind parameters. On Nov 12, 2008, at 9:42 PM, GHZ wrote: > > Hi, > > I am using SQLA for reading from a database. > I modify the objects to use in my code, but don't want to write > anything back to the database. > therefore I call: session.expunge_all() , before reading the next set > of data. > This works, but it results in the select statements being re-parsed by > Oracle. (parse to execute ratio is 1:1) > Is there a way of throwing away all objects from the last fetch > without throwing away the parsed statements? > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected] 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 -~----------~----~----~----~------~----~------~--~---
