Bird
0
0

What will the following query return?

medium📝 query result Q5 of 15
PostgreSQL - Performance Tuning
What will the following query return?
SELECT query, calls, mean_time FROM pg_stat_statements WHERE calls > 100 ORDER BY mean_time DESC LIMIT 2;
AAll queries with mean_time less than 100
BTop 2 queries with the fewest calls
CQueries executed exactly 100 times
DTop 2 slowest queries with more than 100 calls
Step-by-Step Solution
Solution:
  1. Step 1: Understand the WHERE clause

    It filters queries with more than 100 calls.
  2. Step 2: Order by mean_time descending and limit 2

    This returns the top 2 slowest queries by average execution time among those filtered.
  3. Final Answer:

    Top 2 slowest queries with more than 100 calls -> Option D
  4. Quick Check:

    WHERE calls > 100 + ORDER BY mean_time DESC LIMIT 2 = top 2 slowest frequent queries [OK]
Quick Trick: Filter by calls > 100 then order by mean_time DESC [OK]
Common Mistakes:
  • Misreading calls filter
  • Confusing mean_time with total_time
  • Assuming exact calls = 100

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes