mysql - Why the difference in performance when using one index versus multiple indexes -
let's have table named impression
having 3 fields
id site_id timestamp
all 3 fields int
. have run following query
select count( * ) c impression timestamp<unix_timestamp(str_to_date('09,07,2009','%d,%m,%y')) , site_id=11
findings
if define 2 separate indexes, 1 on timestamp
, 1 on site id
results slower. on data set result takes 0.13 s
calculate.
however if define 1 composite index includes both fields in 1 results faster 0.0002 s
question
why indexed fields have under 1 index? if have 2 separate indexes them why don't both of them used
note
yes explain
query that's not question, explain suggests observed, why have 1 index per query
Comments
Post a Comment