Junior — Middle
Can you explain the purpose and principle of the EXPLAIN statement in databases?
sobes.tech AI
Answer from AI
The EXPLAIN statement in databases is used for analyzing and optimizing SQL queries. It shows the execution plan of a query, including the order of reading tables, used indexes, join types, and estimated operation costs.
This helps developers understand how the DBMS processes the query, identify bottlenecks, and improve performance.
Example of usage in MySQL:
EXPLAIN SELECT * FROM users WHERE age > 30;
The result will show which index is used, how many rows are expected to be read, and other details.