I've been experimenting with precompiled queries in my app using the second 
recipe 
on https://bitbucket.org/zzzeek/sqlalchemy/wiki/UsageRecipes/BakedQuery. 
I'm seeing a big speed up, with pages 30-40% faster (my application has 
graph structured content so some pages require ~100 items.) But I'm also 
seeing an increase in the number of db requests as I've had to switch from:

    model = session.query(Resource).get(uuid)

to:

    @precompiled_query_builder(DBSession)
    def _get_by_uuid_query():
        session = DBSession()
        return session.query(Resource).filter(Resource.rid == 
bindparam('rid'))
    ...
    model = _get_by_uuid_query().params(rid=uuid).one()


I think this is due to the identity map not being used. Is there a way to 
precompile queries for .get() and have the best of both?


Laurence

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to