Bird
0
0

Which of the following SQL queries correctly retrieves the index name and scan count from pg_stat_user_indexes?

easy📝 Syntax Q3 of 15
PostgreSQL - Indexing Strategies
Which of the following SQL queries correctly retrieves the index name and scan count from pg_stat_user_indexes?
ASELECT indexrelid, idx_scan_count FROM pg_stat_user_indexes;
BSELECT indexrelname, idx_scan FROM pg_stat_user_indexes;
CSELECT idx_name, scan_count FROM pg_stat_user_indexes;
DSELECT indexname, scans FROM pg_stat_user_indexes;
Step-by-Step Solution
Solution:
  1. Step 1: Check correct column names in pg_stat_user_indexes

    The correct columns are indexrelname for index name and idx_scan for scan count.
  2. Step 2: Verify query syntax

    SELECT indexrelname, idx_scan FROM pg_stat_user_indexes; uses correct column names and syntax. Other options use incorrect column names.
  3. Final Answer:

    SELECT indexrelname, idx_scan FROM pg_stat_user_indexes; -> Option B
  4. Quick Check:

    Correct column names = indexrelname, idx_scan [OK]
Quick Trick: Use exact column names: indexrelname and idx_scan [OK]
Common Mistakes:
  • Using incorrect column names like indexname or scans
  • Misspelling column names
  • Omitting FROM clause

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes