1

I have a table with several indexes. All of them contain an specific integer column. I'm moving to mysql 5.1 and about to partition the table by this column.

Do I still have to keep this column as key in my indexes or I can remove it since partitioning will take care of searching only in the relevant keys data efficiently without need to specify it as key?

2
  • nos and f00. Thanks for the answers. my question is very simple. Its a yes/no question. Commented Sep 7, 2010 at 5:28
  • Then I guess the answer is yes and no. You're not required to have an index on the column you partition by though (see e.g. dev.mysql.com/tech-resources/articles/mysql_5.1_partitions.html for examples). Commented Sep 14, 2010 at 21:37

2 Answers 2

1

Partition field must be part of index so the answer is that I kave to keep the partitioning column in my index.

Sign up to request clarification or add additional context in comments.

Comments

0

Partitioning will only slice the values/ranges of that index into separate partitions according to how you set it up. You'd still want to have indexes on that column so the index can be used after partition pruning has been done.

Keep in mind there's a big impact on how many partitions you can have, if you have an integer column with only 4 distinct values in it, you might create 4 partitions, and an index would likely not benefit you much depending on your queries.

If you got 10000 distinct values in your integer column, you hit system limits if you try to create 10k partitions - you'll have to partition on large ranges (e.g. 0-1000,1001-2000, etc.) in such a case you'll benefit from an index (again depending on how you query the tables)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.