-
-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't use force_index to exec update SQL #1025
Comments
The Does |
Thanks for your response. Index hints can indeed be used in update statements. EXPLAIN UPDATE `sync_businessinfo`
SET `is_deleted` = 0,
`updated_by` = NULL,
`updated_at` = '2023-07-20 17:07:46.138592'
WHERE (`sync_businessinfo`.bk_biz_id IN (0)); when I use explain
UPDATE `sync_businessinfo` force index (`PRIMARY`)
SET `is_deleted` = 0,
`updated_by` = NULL,
`updated_at` = '2023-07-20 17:07:46.138592'
WHERE (`sync_businessinfo`.bk_biz_id IN (0)); I use force index in the update statement because the mysql optimizer will choose not to use the index when the update statement contains a large number of where statements, resulting in serious performance problems I'm going to try to figure out how to implement force index for the update statement |
I think the force index of the update statement cannot be realized through the extra provided by django orm, and it may need to be realized through raw sql |
Raw SQL is not needed if we extend Django-MySQL’s feature. |
Python Version
3.10.11
Django Version
3.2.19
MariaDB/MySQL Version
Mysql 8.0.32
Package Version
4.11.0
Description
I hope to execute the "update" statement through "force_index", but the comment in the actual executed sql becomes "where 1", I'm not sure if this is normal behavior.
project settings
i try to use this orm code
but I watch the original sql
this is the result
for other index name,these sqls are same
I don't know if this is a normal result, please help me to confirm, thanks
The text was updated successfully, but these errors were encountered: