MySQL Forums
Forum List  »  MyISAM

Composite index
Posted by: Julian Assange
Date: August 26, 2016 05:44PM

Hello,

I am investigating why mysql optimizer does not utilise indexes that cover the entire data required by a query.

For example in a simple query on a myisam test table such as:

Select id,number from test where id = 3 and number = 9

where both columns are defined as int, id is the primary key and there is index1 (id,number) I would assume mysql optimizer would choose index1 so that it would not have to even touch the table and serve the result from the composite index. However looking at explain I can see that it uses the primary index to find the record hence potentially reading from the disk as opposed than from the index -ideally in RAM-.

The interesting thing is that I have used mysqlslap to test performance and, indeed, going with the primary index yields results faster. I have made the test with SQL_NO_CACHE and the result is the same.

Options: ReplyQuote


Subject
Views
Written By
Posted
Composite index
2380
August 26, 2016 05:44PM
1213
August 27, 2016 01:55PM
1259
August 28, 2016 06:18AM
1473
August 29, 2016 11:34PM
1288
August 30, 2016 03:16AM
1194
August 31, 2016 04:48PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.