I'm facing some interesting speed issues with my database that only seem to crop up within sqlalchemy. I have 2 tables in a one-to-one relationship, with about ~1 million rows each. From Python, I grab an object from one table (table A): rowA = session.query(A).limit(1).one()
And then access a row in table B: blah = rowA.b.someRow I noticed that for ~500 of these, it started taking a long time - so I wrapped it in time() calls: time1 = time.time() blah = rowA.b.someRow print time.time() - time1 What I find is that when I run this in Python, it takes ~0.01 seconds per object, but when I execute it directly in the database: EXPLAIN ANALYZE SELECT * FROM a WHERE a.b_pk = 20; It only takes ~0.01 milliseconds! Is there some optimization I can do from within the Model Class definitions, or do I really need to execute raw sql from my code to get raw speed? Thanks, Adrian -- 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 sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.