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.