> The result of this query is 23 rows from a 24,000 row table.
>
> I show a query i constructed by hand (Get every annotation of user
> "msn" on subject "2") as i would run using MysqlDb and cursor. I
> time this by measuring the time taken between executing the query
> and putting each result in a tuple. The running time for this query
> is 0.05s
>
> This is compared to running Annotation.query().filter
> (User.user=="msn").filter(Subject.id=2). The query generated by SQL
> alchemy can be seen in the second declaration of the sql string.
> For purposes of interest i run this generated query (with fields
> filled in manually) through the same MysqlDb cursor. This takes 16
> seconds! 

> A query which returns 23 rows should NOT take 16 seconds 
> to return.
heh, not just like this. 
i have a query that returns 3 objects from about 40 and still takes 10 
seconds on postgres (and 50 on sqlite). it just happens to have about 
15 tables in the From list...

the SA sql has 3 tables as opposed to your hand-made that has 1.
i guess something's wrong with the query building - possibly u want:
allAnn = Annotation.query().join( 'user').filter( User.py_user 
== "msn").join( 'subject').filter( Subject.id == 2 ) 
or
allAnn = Annotation.query().join( 'user').filter( User.py_user 
== "msn").filter( Annotation.subject == somesubject ) 


--~--~---------~--~----~------------~-------~--~----~
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