I have a MySQL (5.6.17) table with a few million records that I wish to partition. In order to do this, I use this query:

ALTER TABLE tablename

Seems to work fine and PHPMyAdmin reports 8 partitions, with the data sufficiently distributed amongst the partitions.

If I repeat the exact same query, PHPMyAdmin again reports 8 partitions, but with a completely different distribution of the data. Every time I run the query, it results in different distributions.

The MySQL documentation says HASH does a modulus on the data, so it should be repeatable and produce the same results every time.

Can anybody explain what is happening? Is PHPMyAdmin reporting it wrong? Does HASH() do something else than a simple modulus?

p.s. The column type used for the ID is an INT and I'm testing on a non-live table, so content is unchanged between queries.

p.p.s. Running EXPLAIN PARTITIONS on some queries seems to indicate the records are partitioned by modulus.

  • Oh, that's another reason why PARTITION BY HASH is useless? What says that the distribution is different? Why do you want to use it? I think there is no use case where it benefits. – Rick James Dec 16 '16 at 17:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.