Bird
0
0

A query uses an index scan on a large table but is slower than expected. You suspect the planner is misestimating row counts. What can you do to improve scan choice?

hard📝 Application Q9 of 15
PostgreSQL - Performance Tuning
A query uses an index scan on a large table but is slower than expected. You suspect the planner is misestimating row counts. What can you do to improve scan choice?
ADrop the index and recreate it with a different name.
BDisable sequential scans globally to force index scans.
CRun ANALYZE on the table to update statistics for better planner decisions.
DRewrite the query without WHERE clause.
Step-by-Step Solution
Solution:
  1. Step 1: Understand planner statistics role

    PostgreSQL uses table statistics to estimate row counts and choose scan types.
  2. Step 2: Update statistics to fix misestimation

    Running ANALYZE updates statistics, helping the planner make better scan choices.
  3. Final Answer:

    Run ANALYZE on the table to update statistics for better planner decisions. -> Option C
  4. Quick Check:

    Fix planner misestimation = C [OK]
Quick Trick: Run ANALYZE to refresh stats and improve scan plans [OK]
Common Mistakes:
  • Disabling sequential scans globally is risky
  • Dropping and renaming indexes doesn't fix stats
  • Removing WHERE clause removes filtering, not scan choice

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes