Bird
0
0

You have a large logs table with millions of rows. You want to improve query speed for recent logs and easily drop old logs. Which partitioning strategy is best?

hard📝 Application Q15 of 15
PostgreSQL - Table Partitioning
You have a large logs table with millions of rows. You want to improve query speed for recent logs and easily drop old logs. Which partitioning strategy is best?
ANo partitioning, just add indexes
BHash partitioning by log message content
CRange partitioning by log date, creating monthly partitions
DList partitioning by log severity levels
Step-by-Step Solution
Solution:
  1. Step 1: Understand the data and goals

    Logs are time-based; queries focus on recent data and dropping old data is needed.
  2. Step 2: Choose partitioning strategy

    Range partitioning by date with monthly partitions allows fast queries on recent logs and easy removal of old partitions.
  3. Final Answer:

    Range partitioning by log date, creating monthly partitions -> Option C
  4. Quick Check:

    Time-based data = range partitioning [OK]
Quick Trick: Use range partitions by date for time-based data [OK]
Common Mistakes:
  • Choosing hash partitioning for time-based queries
  • Using list partitioning on severity which doesn't help date queries
  • Skipping partitioning and relying only on indexes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes