Bird
0
0

You have a large table logs with a timestamp column event_time. You want to speed up queries filtering recent events. Which indexing strategy is best?

hard📝 optimization Q8 of 15
PostgreSQL - Indexing Strategies
You have a large table logs with a timestamp column event_time. You want to speed up queries filtering recent events. Which indexing strategy is best?
ACreate a full index on event_time for all rows
BCreate a partial index on event_time for recent dates only
CCreate an index on a different column unrelated to event_time
DDo not create any index to save disk space
Step-by-Step Solution
Solution:
  1. Step 1: Understand partial indexes

    Partial indexes index only rows matching a condition, saving space and improving speed for targeted queries.
  2. Step 2: Apply to recent event filtering

    Creating a partial index on recent event_time values speeds queries filtering recent events efficiently.
  3. Final Answer:

    Create a partial index on event_time for recent dates only -> Option B
  4. Quick Check:

    Partial indexes optimize queries on subsets of data [OK]
Quick Trick: Use partial indexes to speed queries on recent or filtered data [OK]
Common Mistakes:
  • Creating full indexes wasting space
  • Indexing unrelated columns
  • Avoiding indexes to save space but losing speed

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes