代码之家  ›  专栏  ›  技术社区  ›  Amit Kumar Gupta

SQL查询中索引的影响

  •  2
  • Amit Kumar Gupta  · 技术社区  · 15 年前

    1. col1、col2上的索引1

    .. where col1,col4
    .. where col3,col4
    .. where col1,col3 
    .. where col1,col2,col3,col4
    

    *注意,

    1. 我只写了where子句,没有具体说明条件。仅提及使用的列
    2. col4没有任何索引。
    2 回复  |  直到 15 年前
        1
  •  2
  •   Mark Byers    15 年前
    • where col1,col4 col1 从索引1。
    • where col3,col4 -可以使用索引2。
    • where col1,col3 -可以使用index2或prefix 从索引1。
    • where col1,col2,col3,col4 -可以使用任一索引
        2
  •  0
  •   Sachin Shanbhag    15 年前

    where子句中提到的列,如果已索引,则将使用这些索引。例如:在“Where col1,col4”中,col1是索引的,因此它将被使用。其他条件也一样。对于两个索引都可用的列,则可以同时使用这两个索引。例如:在你的第三和第四个where条款中。