Mysql hash partition

MySQLpartitioning

In my system's database we have a table which stores 3 fields: id int, name(varchar) and description (mediumtext). The table is by far the biggest in our database and the queries on it are exclusively by id, which is indexed.

The problem is, we are unable to delete or archive any data and in addition, there is no way to partition the table in a way that will make sense. Currently the performance is good (we're talking about a 7.5 GB table) but I'm afraid we'll encounter some issues in the future.

A colleague suggested me to experiment with hash partitioning, which should divide the table to equally divided groups of data and keep the index level low.

Now my questions regarding this topic are:

  • Is hash partitioning a good solution to solve the issue I'm talking about, or the index is enough considering the queries are only by id

  • In case that I decided to go for hash partitioning, how many partitions should I go for? To remark, the table is currently 7.5 GB and expected to keep growing.

Best Answer

jkavalik is right.

I'll say it more strongly: PARTITION BY HASH is possibly useless in any situation for enhancing performance.

Your table is referenced only by the PRIMARY KEY(id), correct? And it is InnoDB, correct? If you have a million rows, the BTree that contains the PK and all the data is about 3 levels deep. For a _trillion_rows, it will be about 6 levels.

The million-fold increase in data size (from 1M to 1T) might slow down a "point query" by a factor of 2. That's all.