Bird
0
0

You want to find indexes that are rarely used to consider dropping them. Which query helps identify indexes scanned less than 10 times but more than 0?

hard📝 Application Q8 of 15
PostgreSQL - Indexing Strategies
You want to find indexes that are rarely used to consider dropping them. Which query helps identify indexes scanned less than 10 times but more than 0?
ASELECT indexrelname, idx_scan FROM pg_stat_user_indexes WHERE idx_scan > 0 AND idx_scan < 10;
BSELECT indexrelname, idx_scan FROM pg_stat_user_indexes WHERE idx_scan >= 10;
CSELECT indexrelname, idx_scan FROM pg_stat_user_indexes WHERE idx_scan = 0;
DSELECT indexrelname, idx_scan FROM pg_stat_user_indexes WHERE idx_scan > 10;
Step-by-Step Solution
Solution:
  1. Step 1: Define the scan count range

    We want indexes scanned more than 0 but less than 10 times.
  2. Step 2: Translate to SQL WHERE clause

    Use idx_scan > 0 AND idx_scan < 10 to filter indexes in that range.
  3. Final Answer:

    SELECT indexrelname, idx_scan FROM pg_stat_user_indexes WHERE idx_scan > 0 AND idx_scan < 10; -> Option A
  4. Quick Check:

    Filter indexes with scans between 1 and 9 [OK]
Quick Trick: Use AND to combine scan count conditions [OK]
Common Mistakes:
  • Using >= 10 instead of < 10
  • Selecting indexes with zero scans
  • Using OR instead of AND

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes