indexing - Redundant MySQL Index? -
indexing - Redundant MySQL Index? -
action keyname type unique packed column cardinality collation null comment edit drop primary btree yes no tickerid 23200 timestamp 13897209 edit drop tickerid btree no no tickerid 11737 edit drop timestamp btree no no timestamp 18 ~99,424,209 innodb utf8_general_ci 5.1 gib
ok before seek "optimize" db deleting unneeded indexes thought i'd inquire here. table gets nail lot want speed insert performance. read 5 articles on net seem indicate single index on tickerid redundant because multiple index (tickerid,timestamp) used if ever run query on tickerid.
occasionally, eod reporting, might select * timestamp > today() - 1 day or that. need timestamp index well?
this index on tickerid, timestamp can used queries can utilize index on tickerid only.
however, query that:
select * mytable timestamp > today() - 1 an index on (tickerid, timestamp) not used, since there no equality filter on tickerid.
for query, should create index on timestamp or rewrite thу query:
select m.* ( select distinct tickerid mytable ) md bring together mytable m on m.tickerid = md.tickerid , m.timestamp > today() - 1 however, latter query less efficient, if have lots of distinct values in tickerid.
mysql indexing innodb
Comments
Post a Comment