How can I force a query to not use a index on a given table?

后端 未结 3 724
鱼传尺愫
鱼传尺愫 2020-12-24 11:54

I\'m currently doing some testing to determine the performance implications of including an index on a given column in SQL Server 2005.

The test data set I\'m using

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-24 12:44

    SELECT *
    FROM MyTable WITH (INDEX(0))
    WHERE MyIndexedColumn = 0
    

    Query would normally use the index on MyIndexedColumn, but due to the table hint, it will instead tablescan.


    SELECT *
    FROM MyTable WITH (INDEX(IndexName))
    WHERE MyIndexedColumn = 0
    

    Query would normally use the index on MyIndexedColumn, but due to the table hint, it will instead use the index named IndexName.

提交回复
热议问题