Is there a way in SQLalchemy to specify the query which index to use?
The reason I need this is because the SQL queries it generates use the βwrongβ index - there is an index for exactly the two fields that I have, and it does not use it.
Thanks!
I think you can use with_hint () for this.
eg.
session.query(Model).with_hint(Model, 'USE INDEX col1_index')
Honestly, I really did not know about this; I discovered this by finding "USE INDEX" in my ORM tests .
Also useful is http://www.sqlalchemy.org/trac/ticket/921 .