A:
create index idx_owner_name_age on people(name,age); B:
create index idx_owner_name on people(name); 
create index idx_owner_age on people(age); 请问A和B有什么区别?

解决方案 »

  1.   

    复合索引的几个字段是否经常同时以AND方式出现在Where子句中?单字段查询是否极少甚至没有?如果是,则可以建立复合索引;否则考虑单字段索引;
      

  2.   

    首先物理存储上,复合索引和多个单字段索引 是不一样的。
    那么在insert 时 维护索引就有区别查询上,如果经常用多个字段查询,建议建复合索引。
    反之。
      

  3.   

    create index idx_owner_name_age on people(name,age);  如果NAME字段不走索引,AGE字段肯定也不会走索引,如果NAME字段走索引,AGE就会走索引