Senior
Which command helps optimize queries in PostgreSQL?
sobes.tech AI
Answer from AI
To optimize queries in PostgreSQL, the EXPLAIN or EXPLAIN ANALYZE command is often used. It shows the execution plan of a query, allowing you to understand which indexes are used, how many rows are processed, and where potential bottlenecks may be.
Example of usage:
EXPLAIN ANALYZE SELECT * FROM users WHERE email = 'example@example.com';
This helps identify whether additional indexes are needed or if the query should be rewritten for better performance.