Django mysql强制使用索引

2024-10-01 09:41:05 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用的是django-orm和mysql。 由于某种原因,mysql使用了错误的索引。 我想手动覆盖使用的索引。 我看到django团队出于跨平台的原因决定阻止使用with-huntints扩展来强制索引。 有没有人有什么建议可以让mysql使用正确的索引,然后通过django?在

谢谢


Tags: django错误withmysqlorm跨平台原因手动
2条回答

Django支持原始sql查询以满足您的需要,请参阅文档文章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扩展支持索引提示。有关详细信息,请参见the docs。在

相关问题 更多 >