Used in most filters
The column most reports filter on, so queries only read the parts they need.
Partitioning splits large tables into manageable parts. How to choose a key that speeds up loads and queries instead of slowing them.
As transaction tables grow into hundreds of millions of rows, loads take longer, reports slow down, and reloading a single day means touching the whole table. Partitioning splits a table by a key, such as month, so the database can load, query, and archive one part at a time. With the right key, that’s a big improvement. With the wrong one, every query has to search every part and it gets slower.
The column most reports filter on, so queries only read the parts they need.
New data lands in one part, so loads and reloads touch as little as possible.
A record shouldn’t have to move between parts after it’s loaded.
Parts of roughly similar size, without one huge part and many tiny ones.
Step 1 of 4
Find the reports and loads that take longest and what they filter on.
See whether data arrives by day, by store, or in another pattern.
Day, month, or year, based on data volume and how far back reports look.
Measure load and query times on a partitioned copy before changing the live table.
For most sales, order, and stock movement tables, the transaction date, partitioned by month, meets every criterion. For example: reloading last month replaces one part, reports for this quarter read three parts, and archiving old years is a quick swap. Don’t partition small tables at all; an index is usually enough.
Tell us which tables are growing and which reports are slow. A few lines are enough.