select * from where uid=N and sid=M
只给uid建单字段索引的效果,
分别给 uid和sid建单字段索引的效果,
给 uid和sid建多字段索引的效果。
这三种有什么不同? 

解决方案 »

  1.   

    三种方法的效果如下(如果不是非常大的数据量,千万级,没有必要):只给uid建单字段索引的效果
    select * from where uid=N分别给 uid和sid建单字段索引的效果,
    select * from where uid=N
    select * from where sid=M给 uid和sid建多字段索引的效果
    select * from where uid=N and sid=M
      

  2.   

     where uid=N and sid=M这种应用下,创建复合索引 (uid,sid) 
      

  3.   

    MySQL官方文档 http://dev.mysql.com/doc/refman/5.1/zh/index.html
      

  4.   

    当您的问题得到解答后请及时结贴.
    http://topic.csdn.net/u/20090501/15/7548d251-aec2-4975-a9bf-ca09a5551ba5.html
      

  5.   

    修正一下二楼的说法:
    三种方法的效果如下(如果不是非常大的数据量,千万级,没有必要):只给uid建单字段索引的效果
    select * from where uid=N分别给 uid和sid建单字段索引的效果,
    select * from where uid=N or sid=M给 uid和sid建多字段索引的效果
    select * from where uid=N and sid=M