mysql - The ordering of indexes group -
i read somewhere there different between these 2 indexes groups:
add key id_user (id_user,seen);
add key id_user (seen,id_user);
well there? if yes order should based on parameter?
in reality have these 2 queries on 1 table:
query1:
select * mytable id_user = :id , seen null
query2:
select * mytable id_user = :id , timestamp > :tm
so kind of indexes proper in case? have 3 separated indexed on id_user
, seen
, timestamp
columns.
both queries have equality condition on id_user
. hence, either can take advantage of index id_user
first key in index. so, recommend first index mention.
mysql has documentation on multi-column indexes. suggest start there learn them.
your query can take advantage of indexes on (id_user, seen)
, (id_user, timestamp)
. probably, first key important. should try different indexes , see best meet performance goals.
Comments
Post a Comment