Add USE INDEX, FORCE INDEX capabilities to ORM
|Reported by:||Renato Alves||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||master|
|Severity:||Normal||Keywords:||INDEX USE FORCE|
|Cc:||clouserw@…, rkm, Simon Litchfield||Triage Stage:||Design decision needed|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||yes||Patch needs improvement:||no|
Recently I've add significant performance issues with Django + MySQL.
The reasons behind this are MySQL not using an existing index due to low cardinality and instead do a full table scan. In most cases this is the correct choice but there some exceptions. For these, the workaround is to add "FORCE INDEX (index_name)" to the SQL.
However there is no support for this feature in the ORM.
As for the relevance of this functionality, in my case, query time was 0.09 sec when using FORCE INDEX and 10.3 sec when not.
This problem becomes more visible if the columns involved are used in several JOIN operations.
Change History (8)
comment:5 Changed 7 years ago by
|Cc:||rkm Simon Litchfield added|
|Status:||closed → reopened|