Bird
0
0

Given the query:

medium📝 query result Q4 of 15
PostgreSQL - Performance Tuning
Given the query:
SELECT query, calls, total_time FROM pg_stat_statements ORDER BY total_time DESC LIMIT 3;

What does this query return?
AThe 3 most recent queries executed
BThe 3 queries with the fewest calls
CThe 3 queries with the lowest average execution time
DThe 3 queries with the highest total execution time
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the ORDER BY clause

    The query orders by total_time DESC, so it sorts queries by total execution time from highest to lowest.
  2. Step 2: Understand the LIMIT clause

    LIMIT 3 restricts output to top 3 rows after sorting.
  3. Final Answer:

    The 3 queries with the highest total execution time -> Option D
  4. Quick Check:

    ORDER BY total_time DESC LIMIT 3 = top 3 slowest total time queries [OK]
Quick Trick: ORDER BY total_time DESC shows slowest total time queries [OK]
Common Mistakes:
  • Confusing total_time with calls
  • Assuming it shows recent queries
  • Thinking it orders by average time

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes