How MySQL Uses Indexes
Posted by:
Mola Ji
Date: May 04, 2013 08:28AM
I create a table as follows:
CREATE TABLE IF NOT EXISTS `t` (
`id` int (11) NOT NULL AUTO_INCREMENT,
`i` date NOT NULL,
`o` date NOT NULL,
PRIMARY KEY (`id`),
Index0 KEY `` (`i`)
)
to test the performance of my query I do:
explain select * from t o Where> '2013-05-04 'and i <'2013-05-11';
I got the following output on my local computer:
| select_type | table | Type | possible_keys | key | key_len | ref | rows
+ ---- + ------------- + ------- + ------- + -------------- - + ------ + --------- +
| SIMPLE | t | range | a, b | b | 3 | NULL | 84 | Using where |
+ ---- + ------------- + ------- + ------- + -------------- - + ------ + --------- +
While on a remote server, I get:
| select_type | table | Type | possible_keys | key | key_len | ref | rows
+ ---- + ------------- + ------- + ------- + -------------- - + ------ + --------- +
| SIMPLE | t | ALL | a, b | null | 3 | NULL | 84 | Using where |
+ ---- + ------------- + ------- + ------- + -------------- - + ------ + --------- +
This means that MySQL uses the index locally, but not on the remote server. Why?
Subject
Views
Written By
Posted
How MySQL Uses Indexes
2231
May 04, 2013 08:28AM
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.