Is there a way to explain a DELETE
query with MySQL like we can explain a SELECT
query?
Asked
Active
Viewed 1.4k times
19

Gaël J
- 11,274
- 4
- 17
- 32

user217631
- 1,278
- 5
- 18
- 33
3 Answers
39
"As of MySQL 5.6.3, EXPLAIN provides information about SELECT, DELETE, INSERT, REPLACE, and UPDATE statements. Before MySQL 5.6.3, EXPLAIN provides information only about SELECT statements."

Niro
- 776
- 8
- 15
10
Wouldn't the plan for that be the same as for a select 1 where....
with the same condition as your delete
query?
The 1
is so the optimizer isn't forced to pull any unneeded columns, it can only look at the columns it needs for the filtering conditions.

Blindy
- 65,249
- 10
- 91
- 131
1
No, that's not quite right. A DELETE would also remove index entries from any associated indexes (mysql erroneously calls them 'keys'). There are also delete triggers to consider as well.

Jonathan
- 11
- 1
-
As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 01 '22 at 09:42