I recently discovered that I’d made a huge blunder in the Partitioning Limitations section of the MySQL 5.1 Manual. I’d had the idea that unique keys don’t effect your choice of partitioning columns unless there’s no primary key.
My latest revision of the documentation for this limitation isn’t much better.
Then, as I was sitting here just now trying to persuade my daughter that she really ought to have something for lunch besides marshmallows, it came to me.
It’s very simple, really.
For any user-partitioned table in MySQL 5.1:
- If a table has any unique keys, then all columns used in the partitioning expression must also be part of any and all of these keys.
- By definition, a primary key is a unique key.
- If the table has no unique keys, then you don’t have to worry …