Junior — Middle
Explain what the EXPLAIN command does in SQL queries.
sobes.tech AI
Answer from AI
The EXPLAIN command in SQL is used to obtain the execution plan of a query by the database. It shows how the DBMS intends to execute the query: which indexes will be used, how tables will be joined, the order of reading data, etc. This helps understand how efficiently the query is written and where performance optimizations can be made.
Example of usage:
EXPLAIN SELECT * FROM users WHERE age > 30;
The result will show which index (if any) will be used, approximately how many rows will be read, and other details of the execution plan.