Say you have a query like
select ID, REGION, START, END from COORD_SYSTEM where REGION=? and TYPE=? and START >= ? and END <= ?;
And let this table have about 50,000 rows. The REGION column has 500 different values, and the TYPE column has 50 different values. The ID column is the primary key.
What would be the best way to index a table? I'm not quite sure if the coverage index was able to get due to the> = and <= icons. Here are a few options:
- create an index on COORD_SYSTEM (REGION, TYPE)
- create an index on COORD_SYSTEM (REGION, TYPE, START)
- create an index on COORD_SYSTEM (REGION, TYPE, START, END)
Update - here is the explanation:
id: 1 select_type: SIMPLE table: COORD_SYSTEM type: range possible_keys: indx_A key: indx_A key_len: 50 ref: NULL rows: 590 Extra: Using where 1 row in set (0.00 sec)
source share