Bird
0
0

You want to compare the performance of two queries on a large table. Which approach using EXPLAIN ANALYZE is best?

hard📝 Application Q8 of 15
PostgreSQL - Performance Tuning
You want to compare the performance of two queries on a large table. Which approach using EXPLAIN ANALYZE is best?
ARun EXPLAIN ANALYZE on a different table for comparison
BRun EXPLAIN only (without ANALYZE) on both queries and compare estimated costs
CRun EXPLAIN ANALYZE on one query and EXPLAIN on the other
DRun EXPLAIN ANALYZE on both queries separately and compare actual execution times
Step-by-Step Solution
Solution:
  1. Step 1: Understand goal is to compare real performance

    Actual execution times are needed, so EXPLAIN ANALYZE must be run on both queries.
  2. Step 2: Evaluate options

    Only running EXPLAIN shows estimates, mixing EXPLAIN and EXPLAIN ANALYZE is inconsistent, and comparing different tables is invalid.
  3. Final Answer:

    Run EXPLAIN ANALYZE on both queries separately and compare actual execution times -> Option D
  4. Quick Check:

    Compare real times = EXPLAIN ANALYZE both queries [OK]
Quick Trick: Use EXPLAIN ANALYZE on both queries for real time comparison [OK]
Common Mistakes:
  • Comparing estimated costs instead of actual times
  • Mixing EXPLAIN and EXPLAIN ANALYZE outputs
  • Comparing queries on different tables

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes