A BRIN index for append-only time series
Events inserted in time order are physically in time order on disk. A B-tree on the timestamp indexes every row. A BRIN indexes ranges of pages, is a few hundred kilobytes for a table of hundreds of gigabytes, and skips almost everything on a date range query.
CREATE INDEX events_ts ON events USING brin (created_at);Wrong for tables that get updated in place. Right for logs, events and metrics.
postgresqlperformance
Longer version: the post this came from.