# 2.3 The Industrial Label (BRIN) ![The BRIN Post-it Notes](assets/arch_index_brin.png) When the depot becomes truly infinite (petabytes of data!), even the Index Clerk gets overwhelmed. He can't keep a map of every suitcase; his tiny hands would fall off! For these cases, we use a **BRIN** (Block Range Index). It is the ultimate expression of the Lazy Elephant’s philosophy. ## The Binoculars Approach Why look closely when you can look from afar? The BRIN index acts as a pair of **Magical Binoculars**. Imagine a line of massive, identical stone blocks stretching into the infinite distance. Instead of keeping a detailed map of every suitcase inside, the elephant just sticks a tiny, simple **Yellow Post-it Note** on the side of each block. The note only says two things: "The smallest number in this block is 100, and the largest is 200." When searching for ID 150, the elephant stands far back and uses his binoculars to read the post-it notes. If a note says "10-50," the elephant knows he doesn't even need to walk over to that block. He just skips it entirely! BRIN is the ultimate lazy index—it doesn't tell you where something IS, it only tells you where it definitely **ISN'T**. It’s a map of everywhere you shouldn't go! ### The Binocular Boost Let's look at a range query on our massive `supply_deliveries` table: #### State 1: The Infinite Aisle (Before BRIN) ```sql EXPLAIN SELECT count(*) FROM supply_deliveries WHERE delivery_time BETWEEN '2024-01-01' AND '2024-01-31'; -- Results: -- Seq Scan on supply_deliveries (cost=0.00..1845.00 rows=2880 width=0) ``` #### State 2: The Quick Glance (After BRIN) ```sql -- Sticking the Post-it Notes on the blocks CREATE INDEX idx_deliveries_brin ON supply_deliveries USING brin(delivery_time); EXPLAIN SELECT count(*) FROM supply_deliveries WHERE delivery_time BETWEEN '2024-01-01' AND '2024-01-31'; -- Results: -- Bitmap Heap Scan on supply_deliveries (cost=12.00..54.00 rows=2880 width=0) -- -> Bitmap Index Scan on idx_deliveries_brin (cost=0.00..12.00 rows=2880 width=0) ``` The elephant just glanced at the notes and skipped 90% of the depot! For the technical manual on BRIN ranges, see the **[[Structures/Index/BRIN|BRIN Reference]]**. --- [[Chapter 2/2.2 - The Word Scavenger (GIN & GiST)|← 2.2 - GIN & GiST]] | [[Chapter 2/2.0 - The Mighty Indexes|↑ 2.0 - The Mighty Indexes]] | [[Chapter 2/2.4 - The Scent Tracker (Vector Search)|2.4 - Vector Search →]]