Foundationপ্রথম নীতি থেকে
LEVEL 8 · Database Systems

BRIN

ব্রিন

Block Range Index — ডিস্কের পরপর block-গুলোর min/max summary; বিশাল append-only table-এর ক্ষুদ্র index।

also: block-range-index

ধরন: time-series, log, event table — created_at মোটামুটি ডিস্কেও sorted। BRIN প্রতি range (default 128 blocks) -এ এক tuple রাখে: min, max, null bitmap।

CREATE INDEX events_created_brin ON events USING brin (created_at)
  WITH (pages_per_range = 64);

SELECT * FROM events
WHERE created_at BETWEEN '2026-08-01' AND '2026-08-07';
  • Size: B-tree-র হাজার ভাগের এক — GB-scale index vs MB-scale
  • Query: range-এর min/max overlap হলে candidate pages → heap read → filter (lossy by design)
  • Correlation মানে physical order ≈ column order — ভাঙলে (random update) BRIN অকেজো

Correlated data + huge table = BRIN-এর জয়; random access pattern = B-tree-ই থাকুক।