Overview
Split data into hot and cold tiers once old rows bloat the indexes, backups, and cache that recent queries need. Hot data lives on fast disks and in cache. Cold data (audits, compliance archives, historical analytics) moves to slower disks, compressed partitions, or object storage. Define the aging rule by access pattern, not table size.
Rules
- In PostgreSQL, implement tiers with time-based partitioning (partition-key). Detach or drop old partitions instead of running a huge
DELETE, move a cold partition to a slower tablespace withALTER TABLE ... SET TABLESPACE, or export it to object storage (for example Parquet). pg_partmanautomates partition creation and retention.- Start with time partitions and manual moves before investing in automated tiering.
- A query that scans cold partitions is slow whatever the hot tier does; route by recency in the application or a view.
Example: a 500 M-row audit log is queried daily for the last 30 days and only for compliance after that. Monthly partitions let the hot partitions fit in memory while old ones are archived.
Related
- partition-key: the column that defines the hot/cold boundary.
- sharding: spreads data across nodes, not tiers.
- write-amplification: smaller hot tables mean less index upkeep.
- postgres-partitioning: partition management.
- postgres: tablespaces and storage.