Is there a way in SQLalchemy to tell the query which index to use?
The reason I need this is that the SQL queries it generates use the "wrong" index - there exists an index for exactly the two fields that I have and it doesn't use it.
Thanks!
Is there a way in SQLalchemy to tell the query which index to use?
The reason I need this is that the SQL queries it generates use the "wrong" index - there exists an index for exactly the two fields that I have and it doesn't use it.
Thanks!
我认为您可以为此使用with_hint()。
例如
session.query(Model).with_hint(Model, 'USE INDEX col1_index')
老实说,我真的不知道这一点。我通过在他们的ORM 测试中找到“使用索引”来发现它。