Bug #68299 | unexcepted "Using where" in "explain update/delete" | ||
---|---|---|---|
Submitted: | 7 Feb 2013 5:40 | Modified: | 30 May 2013 2:07 |
Reporter: | xiaobin lin (OCA) | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S3 (Non-critical) |
Version: | 5.6 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | explain, range, using where |
[7 Feb 2013 5:40]
xiaobin lin
[7 Feb 2013 5:41]
xiaobin lin
Based on 5.6.10
Contribution: 5.6.10.explain_update_using_where.diff (application/octet-stream, text), 1.40 KiB.
[7 Feb 2013 11:52]
MySQL Verification Team
Thank you for the bug report and contribution.
[8 Apr 2013 8:12]
Jørgen Løland
Hi xiaobin lin, Thank you for the bug report and the contribution. Your suggested modification would change the value of the 'type' column from "range" to "const" for UPDATE statements with equality predicates. Unfortunately, the problem is a bit more complicated than what EXPLAIN outputs because the statement currently does use range access (in contrast to the SELECT statement shown in this bug report). The output of EXPLAIN is therefore correct. The proper way to fix this bug would be to make single-table UPDATEs (and DELETEs) go through the same optimizations that multi-table U/D and SELECTs. This is a bigger task that has become very visible due to the new EXPLAIN UPDATE feature in 5.6. It will be addressed sooner or later, but I can't give a time frame. Your request for increased readability is still a good one though. We have decided to keep "type:range" for the statement in the bug report (since this is what actually happens) but instead change the value of the 'ref' column to "const" in the same way as is shown for queries with type [eq_]ref and const.
[30 May 2013 2:07]
Paul DuBois
Noted in 5.6.12, 5.7.2 changelogs. For DELETE and UPDATE statements, EXPLAIN displayed NULL in the ref column for some cases where const is more appropriate.