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
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.
Spread writes that all land on one row
SCL-40When most requests update one row or key, such as a view counter, split it into several rows or batch the updates. Writers must not queue on one lock.
Watch size and growth
SCL-36Record the size of the database and of its 10 biggest tables every day. Forecast when each disk or plan limit will be 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.