Junior — Middle
What is the purpose of the EXPLAIN command in SQL query analysis?
sobes.tech AI
Answer from AI
The EXPLAIN command is used to analyze the execution plan of an SQL query. It shows how the DBMS will execute the query: which indexes will be used, how tables will be joined, in what order, etc. This helps optimize queries, identify bottlenecks, and improve database performance.
Example of usage in PostgreSQL:
EXPLAIN SELECT * FROM users WHERE age > 30;
The output will show the sequence of operations that the server will perform to obtain the result.