mysql - What happens when I create an index on a column? -
i asked multiple question indexes already. this:
would following queries benefit index? mytable(col1, col2, col3)
. . . col1 = ? , col3 = ? . . . col2 = ? . . . col1 in (?, ?) . . . col3 = ? , col1 not in (?, ?) . . . col1 = ? or col2 = ? . . . col2 = ? , col1 = ? . . . col1 = ? , col2 > ? . . . col1 = ? , col3 > ? -- each question containing 1 of these queries ;-)
every time got answer specific query mentioned in question, , still cannot judge such index useful such query or not. (or how making more optimal)
so decided ask question , want know backstage. happens when create index on column? index made of what? multiple column index containing rows (because order important)? how works causes query faster?
actually need information indexes make me able how can determine proper index (multiple columns or single column) query.
note: have experiences work explain
. , yes know using explain
useful in these cases. need further information.
an index puts value, or part of value in ram faster access. index more 1 column aggregates contents.
so index (col1, col2, col3)
useful queries contain col1
lookups, because col1
left-most.
it more beneficial lookups of col1
, col2
, because after getting matches col1
, can use col2
part too.
finally, col3
part ever used if col1
, col2
have been used already, unlikely useful. may be.
Comments
Post a Comment