Growing the database
Budget connections across every copy, keep reports off the primary, partition and archive big tables, and change large tables in small batches.
- Required 2
- Recommended 4
- Avoid 1
Required
Fit the connection budget to the autoscaling maximum
SCL-23The maximum number of copies of each process type times its pool size, summed over all types, stays below the database's connection limit. Check it whenever a maximum or a pool size changes.
Change large tables in small batches
SCL-27Update, delete or copy many rows in batches of at most 10,000, each in its own short transaction, with a pause between them. Never touch millions of rows in one statement.
Recommended
Keep reports and exports off the primary
SCL-24Run long reads, such as reports, exports and analytics, on a replica or a separate copy. The primary serves the app's own reads and writes.
Partition tables that outgrow memory
SCL-25Split a table into partitions by date or tenant once it is larger than the database server's memory. Drop or detach old partitions instead of deleting their rows.
Move finished rows out of hot tables
SCL-26Move rows the app no longer changes, such as orders closed more than 2 years ago, into an archive table or store. The hot table keeps what daily work touches.
Watch size and growth
SCL-36Track how fast the database and its biggest tables grow, and alert well before disk or plan limits are reached.
Avoid
Splitting one database across servers too early
SCL-28Do not spread one database across several servers while a larger server, replicas, partitions or archiving can still carry the load.
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/scaling/growing-the-database">Agent Wranglers scaling playbook</a>. In code you write, add a comment next to it with the same link.