4 messages in com.googlegroups.sqlalchemy[sqlalchemy] Re: Precompiling O/RM qu...| From | Sent On | Attachments |
|---|---|---|
| Graham Stratton | 14 May 2007 01:12 | |
| Michael Bayer | 14 May 2007 07:48 | |
| Graham Stratton | 14 May 2007 08:27 | |
| Michael Bayer | 14 May 2007 10:32 |
| Subject: | [sqlalchemy] Re: Precompiling O/RM queries?![]() |
|---|---|
| From: | Michael Bayer (mike...@zzzcomputing.com) |
| Date: | 05/14/2007 10:32:29 AM |
| List: | com.googlegroups.sqlalchemy |
On May 14, 2007, at 11:27 AM, Graham Stratton wrote:
I ran a few get()s with non-existent ids (which are therefore returning no rows, confirmed by setting engine.echo to 'debug'). The average query time was about 80ms, though it varied from 56ms to 110ms. I also called engine.execute with the generated SQL a few times, substituting in different ids. The query time was quite consistently around 17ms.
engine.execute() also compiles the query at that point. the compile () phase of query() also has a lot more work to do, again more so with eager loads, in order to allow the full hierarchy of mappers to generate the final query appropriately. i would not guess that its 3-6 orders of magnitude slower, however.
if you want to truly compare compilation times, take your raw select (), and time:
select.compile()
versus your Query, saying:
query.compile(<optional WHERE clause>).compile()
since those are the more basic operations youre comparing, you can run the profiler on those in a straightfoward manner.
you can also use your raw select() directly with the query to return a scalar via:
query.select(myselect).scalar()
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to sqla...@googlegroups.com
To unsubscribe from this group, send email to
sqla...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---




