Bird
0
0

Given a table logs with a BRIN index on log_time, what will the following query most likely do?

medium📝 query result Q13 of 15
PostgreSQL - Indexing Strategies
Given a table logs with a BRIN index on log_time, what will the following query most likely do?
EXPLAIN ANALYZE SELECT * FROM logs WHERE log_time BETWEEN '2024-01-01' AND '2024-01-31';
AUse a bitmap index scan instead of BRIN.
BPerform a full sequential scan ignoring the BRIN index.
CThrow a syntax error because BRIN indexes cannot be used in WHERE clauses.
DUse the BRIN index to quickly scan only relevant block ranges.
Step-by-Step Solution
Solution:
  1. Step 1: Understand BRIN index behavior on range queries

    BRIN indexes speed up range queries by scanning only relevant block ranges.
  2. Step 2: Analyze query and options

    The query filters by a range on log_time, so the BRIN index will be used to limit scanned blocks.
  3. Final Answer:

    Use the BRIN index to quickly scan only relevant block ranges. -> Option D
  4. Quick Check:

    BRIN helps range scans by block filtering [OK]
Quick Trick: BRIN speeds up range scans by filtering block ranges [OK]
Common Mistakes:
  • Assuming BRIN causes full table scan
  • Thinking BRIN causes syntax errors
  • Confusing BRIN with bitmap indexes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes