This blog was originally published in July 2017 and was updated in August 2023.
It’s a pretty common question around here, so let’s see what we can do about that.
So, What is MySQL Partitioning?
Partitioning is a way in which a database (MySQL in this case) splits its actual data down into separate tables but still gets treated as a single table by the SQL layer.
When partitioning in MySQL, it’s a good idea to find a natural partition key. You want to ensure that table lookups go to the correct partition or group of partitions. This means that all SELECT, UPDATE, and DELETE should include that column in the WHERE clause. Otherwise, the storage engine does a scatter-gather and queries ALL partitions in a UNION that is not concurrent.
Generally, you must add the partition key into the primary key along …
[Read more]