| Key | Default | Extra | +-------------+----------+------+-----+---------+----------------+ | ID | int(11) | NO | PRI | NULL | auto_increment | | Name | char(35) | NO | | | | | CountryCode | char(3) | NO | MUL | | | | District | char(20) | NO | | | | | Population | int(11) | NO | | 0 | | +-------------+----------+------+-----+---------+----------------+ 5 rows in set (0.00 sec) Friday 14 February 14
*************************** 1. row *************************** id: 1 select_type: SIMPLE table: City type: ALL possible_keys: NULL key: NULL key_len: NULL ref: NULL rows: 4188 Extra: Using where 1 row in set (0.00 sec) Friday 14 February 14
*************************** 1. row *************************** rows: 4188 Extra: Using where 1 row in set (0.00 sec) mysql> create index Name on City (Name); Query OK, 0 rows affected (0.04 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> explain select * from City where Name = "Gent"\G *************************** 1. row *************************** table: City type: ref possible_keys: Name key: Name key_len: 35 ref: const rows: 1 Extra: Using index condition 1 row in set (0.00 sec) Friday 14 February 14
and Population < 27000\G *************************** 1. row *************************** id: 1 select_type: SIMPLE table: City type: ref possible_keys: Name,Population key: Name key_len: 35 ref: const rows: 1 Extra: Using index condition; Using where 1 row in set (0.00 sec) Friday 14 February 14
and Population < 27000\G *************************** 1. row *************************** id: 1 select_type: SIMPLE table: City type: range possible_keys: Name,Population key: Population key_len: 4 ref: NULL rows: 64 Extra: Using index condition; Using where 1 row in set (0.00 sec) Friday 14 February 14
affected (0.05 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> explain select * from City where Name like "G%" and Population < 27000\G *************************** 1. row *************************** id: 1 select_type: SIMPLE table: City type: range possible_keys: Name,Population,NameAndPopulation key: Population key_len: 4 ref: NULL rows: 64 Extra: Using index condition; Using where 1 row in set (0.00 sec) Friday 14 February 14
and Population < 27000\G *************************** 1. row *************************** id: 1 select_type: SIMPLE table: City type: range possible_keys: Name,Population,NameAndPopulation key: NameAndPopulation key_len: 39 ref: NULL rows: 16 Extra: Using index condition 1 row in set (0.00 sec) Friday 14 February 14