Try a bigger box (vertical scaling) first. Partition next if the problem is one huge table with one slow query shape, and add replicas if it is read volume rather than table size. Shard last, and only once you’ve measured that a single server’s write throughput, not query shape, is the wall.
Sizing a bigger box is measured in the buffer pool guide; read scaling via replicas, with a real replication setup and a measured lag number, is in the MySQL scale-out page. What’s genuinely left, and isn’t published anywhere else here, is MySQL’s own native partitioning: the free, single-server middle ground between “buy a bigger box” and “run more servers”. It is demonstrated below with real EXPLAIN output and a real error.
Table of Contents
The trade-off between vertical and horizontal scaling
Vertical scaling is bounded by one machine’s ceiling — RAM, CPU, disk I/O — and nothing else changes: same schema, same connection string, same transactional guarantees. Horizontal scaling removes that ceiling by adding machines, and in exchange hands you problems a single server never had: which node has the current data, what happens when a write reaches one node but a read hits another, and — for anything beyond read replicas — how a query that needs rows from two different servers gets answered at all. That trade, not a checklist of pros and cons, is the whole decision.
Native partitioning: horizontal-shaped, but still one server
MySQL ships table partitioning in core — no plugin, no extension. A real range-partitioned table on this machine’s MySQL 8.4.10, 360 rows spread across three yearly partitions:
CREATE TABLE sales (
sale_id BIGINT NOT NULL AUTO_INCREMENT,
sale_date DATE NOT NULL,
amount DECIMAL(10,2),
PRIMARY KEY (sale_id, sale_date)
) ENGINE=InnoDB
PARTITION BY RANGE (YEAR(sale_date)) (
PARTITION p2024 VALUES LESS THAN (2025),
PARTITION p2025 VALUES LESS THAN (2026),
PARTITION p2026 VALUES LESS THAN (2027)
);
A literal-date query touches one partition — MySQL’s EXPLAIN names it directly in a partitions column, unedited:
EXPLAIN SELECT * FROM sales WHERE sale_date = '2025-06-15';
partitions: p2025
rows: 122 filtered: 10.00
MySQL prunes on a constant subquery too. Per PostgreSQL’s partition pruning docs, PostgreSQL can’t use a subquery’s value at plan time, but it prunes at execution time instead, and EXPLAIN ANALYZE can show the skipped partitions as (never executed) (see also this same site’s PostgreSQL partitioning vs. sharding page). Here it is in MySQL:
EXPLAIN SELECT * FROM sales WHERE sale_date = (SELECT '2025-06-15');
partitions: p2025 -- still one partition, not three
But join the same column against another table’s value, and MySQL’s pruning stops:
EXPLAIN SELECT s.* FROM sales s JOIN lookup l ON s.sale_date = l.d;
partitions: p2024,p2025,p2026 -- all three, every time
PostgreSQL differs on this one: its docs say execution-time pruning covers “values from execution-time parameters such as those from parameterized nested loop joins”, so a join can still prune there. The lesson is the same as on the PostgreSQL page, though: check EXPLAIN‘s partitions column, don’t assume pruning is happening because the table is partitioned.
The primary key restriction PostgreSQL shares
MySQL requires every unique key — including the primary key — to contain every column used in the partitioning expression. PostgreSQL’s partitioning limitations include a version of the same rule: a primary key or unique constraint on a partitioned table must include every partition key column, and is refused outright when the partition key uses an expression or function call. In MySQL, try a primary key on sale_id alone with the same PARTITION BY RANGE (YEAR(sale_date)):
ERROR 1503 (HY000): A PRIMARY KEY must include all columns in the table's
partitioning function (prefixed columns are not considered).
Real, current, unedited — MySQL 8.4.10 refuses to create the table at all. That’s why the working example above has a composite key, PRIMARY KEY (sale_id, sale_date), instead of the single-column key you’d normally reach for. This single restriction is often the actual blocker when someone tries to retrofit partitioning onto an existing table. The three partitions: results and the 1503 refusal above are asserted by horizontal-vs-vertical-scaling.sh, which needs a MySQL server reachable as root and only prints the command that removes the database it creates, never running it.
Where partitioning stops and sharding starts
Every partition above lives in the same mysqld process, the same information_schema, backed up by the same mysqldump. Sharding — splitting rows across genuinely separate MySQL servers — is a different kind of problem, and MySQL has no built-in mechanism for it: no core equivalent to a shard-routing layer. Getting there means external tooling (Vitess, ProxySQL, or hand-rolled application-level routing) or the replication setup this site already demonstrates for the read-scaling half of the problem. None of that tooling is installed on this machine, so nothing about it is demonstrated here — cite each tool’s own documentation before adopting it.
Which to try first: bigger box, partitioning, replicas or sharding
Reach for a bigger box first — see the buffer-pool guide for what that ceiling actually looks like on real hardware. Reach for partitioning next; it’s free, native, and fixes the actual problem (“one huge table, one query shape slow”) far more often than people expect. Reach for replicas when the problem is read volume, not table size — the scale-out page has a real replica lag number to calibrate against. Reach for sharding only once you’ve measured that a single server’s write throughput, not query shape, is the wall — and go in accepting the routing and consistency cost this page opened with, because nothing about it gets simpler once you’re running it in production.