18

Is there a way to explain a DELETE query with MySQL like we can explain a SELECT query?

Gaël J
  • 7,665
  • 4
  • 16
  • 29
user217631
  • 1,258
  • 5
  • 18
  • 31

2 Answers2

37

"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."

from http://dev.mysql.com/doc/refman/5.6/en/explain.html

Niro
  • 756
  • 8
  • 15
9

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
  • 60,429
  • 9
  • 84
  • 123