A BRIN index, short for Block Range Index, is a compact secondary index that stores a small summary per range of physical table blocks, typically the minimum and maximum value of the indexed column, instead of one entry per row. In database indexing, BRIN is designed for very large tables whose physical row order correlates with column values, such as append-only event logs keyed by timestamp.
PostgreSQL introduced BRIN in version 9.5, and comparable ideas exist elsewhere as zone maps, storage indexes and min-max skipping in columnar formats. The approach trades precision for size: a BRIN index can be hundreds or thousands of times smaller than a B-tree index on the same column, but it only narrows a search to candidate block ranges, which must then be scanned and rechecked.
How a BRIN index summarizes block ranges
A BRIN index works by dividing the table heap into consecutive block ranges and storing one summary tuple for each range. In PostgreSQL the range size is set by the storage parameter pages_per_range, which defaults to 128 pages of 8 kB, or about 1 MB of heap per summary entry.
For the default minmax operator class, each summary records the lowest and highest value found in its range. When a query asks for created_at BETWEEN '2026-03-01' AND '2026-03-02', the executor compares the predicate with every summary and builds a lossy bitmap of matching ranges. A bitmap heap scan then reads only those ranges and rechecks every row against the original condition, because a range that overlaps the predicate may still contain many rows outside it.
The structure itself has three parts, shown below. Because the summaries are tiny and few, the whole index often fits in a handful of pages and stays permanently in memory.
| Component | Role | Typical size |
|---|---|---|
| Metapage | Stores version and pages_per_range setting | One page |
| Range map (revmap) | Maps each block range to its summary tuple | A few pages per million blocks |
| Summary tuples | Hold min-max or other summary values | Tens of bytes per range |
Why physical correlation decides BRIN effectiveness
A BRIN index is only selective when values that are close in the column are also close on disk. Planner statistics express this as correlation, a value between -1 and 1 that measures how closely physical row order follows logical value order. Values near 1 or -1 produce narrow, non-overlapping ranges; values near 0 produce ranges whose min-max spans cover almost the entire domain, so nearly every range matches every query.
Correlation arises naturally in append-only workloads: sensor readings, financial ticks, audit logs and clickstream data are inserted roughly in time order. It degrades when updates create new row versions in free space elsewhere, when bulk loads arrive unsorted, or when VACUUM frees space that later inserts reuse out of order.
| Column pattern | Typical correlation | BRIN usefulness |
|---|---|---|
| Insert timestamp on append-only log | Close to 1.0 | Excellent |
| Monotonic sequence identifier | Close to 1.0 | Excellent |
| Order date with late corrections | 0.8 to 0.95 | Good, with some extra reads |
| Customer identifier in an order table | Near 0 | Poor, almost no pruning |
| Frequently updated status column | Near 0 | Unsuitable |
BRIN compared with other index types
BRIN complements rather than replaces the B-tree index. A B-tree stores every key with a pointer to its row and answers point lookups in a few page reads, while BRIN stores only range summaries and answers range predicates over huge, ordered data at a fraction of the storage and maintenance cost. Neighboring structures such as the GIN index and GiST index solve different problems, namely multi-valued containment and geometric or nearest-neighbor search.
| Index type | Granularity | Relative size | Best fit |
|---|---|---|---|
| BRIN | One summary per block range | Very small | Range scans on correlated columns |
| B-tree | One entry per row | Large | Equality, sorting, selective ranges |
| Hash | One entry per row | Medium | Equality only |
| GIN | One entry per contained element | Large | Arrays, JSON, full-text search |
| Partitioning | One partition per key range | No index storage | Pruning plus data lifecycle management |
BRIN cannot enforce uniqueness, cannot return rows in index order and cannot support an index-only scan, because it never stores individual keys. It also gives the query planner only a rough cost estimate, so an explain plan with buffer counts is the reliable way to confirm a benefit.
Operator classes and tuning parameters
The behavior of a BRIN index is shaped by its operator class and a few storage parameters. Since PostgreSQL 14, the minmax-multi class keeps several smaller intervals per range, which tolerates outliers and moderately unsorted data, and the bloom class stores a Bloom filter that supports equality lookups on columns without useful ordering. The inclusion class summarizes geometric and network types with a bounding value.
| Setting | Effect | Trade-off |
|---|---|---|
| pages_per_range | Sets how many heap pages share one summary | Smaller values prune better but enlarge the index |
| autosummarize | Summarizes new ranges after they fill | Adds background work for autovacuum |
| minmax-multi operator class | Stores multiple intervals per range | Larger summaries, better outlier tolerance |
| bloom operator class | Supports equality on unordered values | Probabilistic false positives, no range queries |
A practical starting point is the default range size, followed by measurement. Lowering pages_per_range to 16 or 32 often reduces the number of heap pages read for narrow time windows, while the index remains small by B-tree standards.
Maintenance, limitations and common mistakes
New rows appended beyond the last summarized range are not covered until summarization runs, either through autovacuum, the autosummarize option or an explicit call to brin_summarize_new_values(). Unsummarized ranges are always treated as matches, so queries stay correct but scan more data. Deleting rows does not narrow an existing summary; summaries only widen until a range is desummarized and rebuilt.
- Indexing an uncorrelated column produces an index the planner uses but that prunes almost nothing.
- Expecting point-lookup speed ignores the recheck cost of reading whole 1 MB ranges.
- Large unsorted bulk loads widen many summaries at once; sorting before loading preserves pruning.
- Heavy updates scatter new row versions and erode correlation over time.
In plain words
Picture a long shelf of diaries kept in date order. Instead of listing every entry, a sticky note on each box says which dates it covers, from the first day to the last. To find March entries, you open only the boxes whose notes include March.
A BRIN index is that set of sticky notes for a database table. It is tiny and cheap to keep, but it only works well when the data really sits in order. If the diaries are shuffled, every note covers the whole year and helps nobody.
A real-world example
An industrial monitoring team stores readings from 40,000 sensors in a PostgreSQL table that grows by about two billion rows per month. Rows arrive in timestamp order, and engineers usually query a single sensor group over a few hours. A B-tree index on the timestamp column had grown to roughly 60 GB and slowed every insert.
The team replaced it with a BRIN index on the timestamp using pages_per_range = 32. The new index occupies under 10 MB, insert throughput rises noticeably, and typical six-hour queries read only the matching block ranges. Queries by sensor identifier still use a separate B-tree, so each index serves the access pattern it fits.