Well the queries are totally different... > SELECT * FROM test WHERE id IN (SELECT test.id FROM test LIMIT 100000)
That's 100% in your database, and a single executable. > SELECT * FROM test WHERE id IN ( 1...100000 ) You have SQL Alchemy generating that query & all the bind params, then transmitting it to the DB, then the DB doing it's own testing against the bind values (which could be different than in the first query, depending on the DB ). If you're on PostgreSQL , try both queries with an """EXPLAIN ANALYZE""" ( ie, EXPLAIN ANALYZE SELECT.... ) I forget the MySQL and Oracle commands to profile. You can also use SqlAlchemy events to time the query generation -- I posted a question within the past 3 weeks on this, and it has some sample code references from Mike Bayer in one of the responses. The events will let you know how much time is spent on compiling the query and other tools. IIRC, you still need to time the actual query in the DB . -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/groups/opt_out.
