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

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -