On Nov 8, 2009, at 6:21 AM, Adam Dziendziel wrote:

>
>
> After some tests with weak_identity_map=False see that the source of
> the ORM queries for attributes is not related to garbage collection.
> They aren't issued if query caching is off, so the problem is related
> to caching.
>
> When I write:
>
> theme = session.query(Theme).cache_key(....).get(..) # gets from cache
> print theme.id # here the 'id' attribute access issues a new SELECT

> When the cached object is accessed first, no queries are issued, then
> I do a lot of other record creation and flushing (I'm assigning this
> 'theme' to that records' attributes), then the cache is accessed again
> and this is the moment when the unwanted queries are issued. It seems
> that my record creation and flushing between cache calls makes that
> the ORM expires the cached object. However, the 'theme' object is
> itself never modified.
>
> What might be important, they queries aren't issued if the whole long-
> running operation is run inside a big transaction.
>
> My caching query implementation is here: http://pastebin.com/mf738cc5
> I am using a Session with autoflush=False, autocommit=True.
>
> Do you know what might cause that behavior?

that behavior occurs if "theme" has been expired.   this is  
"expire_on_commit" which you should probably disable, since the fact  
that you are "caching" the objects means you aren't concerned about  
new state coming in from transactions external to your application  
thread.    http://www.sqlalchemy.org/docs/05/session.html#committing




--~--~---------~--~----~------------~-------~--~----~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to