I have a myISAM table with 30 partitions. The primary key is a SHA1 hash value, which is also used in the partition selection function. I also have an alternate key – an autoincrement integer. Since the alternate key does not include the value used in the partition selection function, selecting on the alternate index can't use "partition pruning". Therefore, a select for an alternate key must involve searches on all 30 partitions. This much makes sense.
I was recently told that such a search is carried out serially — on one partition after another. I find this hard to believe, since it sounds like something that could easily be done concurrently. Can anyone confirm this behavior?
mySQL 5.6.14
Best Answer
I agree that MySQL has to do search all 30 partitions. Since you are searching by an auto_increment column, it must be declared as a PRIMARY KEY.
Since indexes are BTREEs, I would expect O(log n) search time per partition.
MySQL (really Oracle) says in the Documentation on Partitioning Overview:
Given these comments about partitions being processed in parallel on their wishlist, it would have to be true at this present time to say that all partitions have to be searched sequentially.
UPDATE 2014-02-21 10:51 EST
With regard to your original question, you stated
OBSERVATION #1
Given the fact that SHA1 output is always 40 characters, my guess is that you are not using RANGE partitioning.
Here is what MySQL Documentation says on HASH partitioning
Since you are not using RANGE partitioning
The overall problem is that the PRIMARY KEY is not an INT. You cannot set up any real RANGE partitioning for a non-scalar type (such as CHAR string). Given this scenario, MySQL cannot avoid doing a SELECT lookup without opening every partition.
OBSERVATION #2
A partitioned MyISAM table with 30 partitions is made up of
.MYD
files.MYI
filesEach MYD requires a file handle. Each MYI requires a file handle. Thus, you can have 60 file handles open. Here is what you can do to see how many file handle open up after a mysql restart
What you can conclude:
The second bulletpoint is what you want because it will show how heavy handed MySQL is at opening partitions,... or not.