Middle+
Describe a situation where you had to use EXPLAIN ANALYZE.
sobes.tech AI
Answer from AI
EXPLAIN ANALYZE is used to analyze the performance of SQL queries. For example, when a database query runs slowly, I used EXPLAIN ANALYZE to get a detailed execution plan with real-time for each step.
This helped identify bottlenecks, such as missing indexes or inefficient table joins. After analysis, I optimized the query or added necessary indexes, which significantly sped up the application.
Example of usage in PostgreSQL:
EXPLAIN ANALYZE SELECT * FROM users WHERE email = 'example@example.com';
The result shows how long each step took, the number of rows processed, and index usage.