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 sqlalchemy@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to