On Jul 12, 2013, at 7:03 PM, Amir Elaguizy <aelag...@gmail.com> wrote:
> I'd like a way to avoid the cost of repeatedly compiling the same query, > especially in the context of relationship caching. > > Specifically now that I have object caching in place, I have created my own > keys where it is possible. However there are still some cases where I cannot. > In these cases I'm falling back to the query based key mechanism: > > stmt = query.with_labels().statement > compiled = stmt.compile() > params = compiled.params > > However this is incredibly slow and what I'm finding is that I'm paying the > cost for compiling the same query with just the parameters themselves > changing. I'd like to create an in memory query cache in which the compiled > queries are stored and the parameters are switched out, or something like > that. See the recipe at http://www.sqlalchemy.org/trac/wiki/UsageRecipes/BakedQuery which will get you most of the way there, and there are plans at some point to make this into a fully supported feature. -- 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/groups/opt_out.