django mysql强制使用索引 [英] django mysql force usage of index
问题描述
从某种原因mysql使用错误的索引。
我想手动覆盖使用的索引。
我看到django团队从跨平台的原因决定了阻止使用强制索引的add_hints扩展名。
如果解决方案\建议我有什么可以让mysql使用正确的索引然后通过django吗?
谢谢
Django支持原始的sql查询以满足您的需要,请参阅文档文章执行原始SQL查询。
当模型查询API不够远,您可以回到编写原始SQL。 Django为您提供执行原始SQL查询的两种方式:可以使用Manager.raw()来执行原始查询并返回模型实例,也可以完全避免模型层,并直接执行自定义SQL。
I'm using django orm and mysql. From some reason mysql is using the wrong index. I want to manually override the index used. I saw that the django team decided from cross platform reason to prevent usage of with_hints extension that would force an index. Does anyone have any kind if solution \ proposal how I could get mysql to use the correct index then through django?
Thanks
Django supports raw sql queries to fit your needs, see the documentation article Performing raw SQL queries.
When the model query APIs don’t go far enough, you can fall back to writing raw SQL. Django gives you two ways of performing raw SQL queries: you can use Manager.raw() to perform raw queries and return model instances, or you can avoid the model layer entirely and execute custom SQL directly.
这篇关于django mysql强制使用索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!