Composite index
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.
Subject
Views
Written By
Posted
Composite index
2600
August 26, 2016 05:44PM
1319
August 27, 2016 01:55PM
1365
August 28, 2016 06:18AM
1575
August 29, 2016 11:34PM
1401
August 30, 2016 03:16AM
1303
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.