PostgreSQL Enterprise (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)
What is a BRIN (Block Range Index) and why does it use 99% less RAM than B-Tree?
senior LevelMost AskedSystem DesignDatabases & SQLData Structures
In Simple Words: On a 1 TB table, a B-Tree index might require 50 GB of RAM:
- BRIN Index: Groups physical disk blocks (e.g. 128 pages = 1 MB chunk) and stores only the minimum and maximum value found within that chunk.
- For naturally ordered data (e.g.
created_atin an append-only log): - A BRIN index requires only a few megabytes of RAM (often < 10 MB!) while delivering near B-Tree query speeds for range queries!