SqlSrv数据库指定索引

Sql srv数据库中,当运行这么一条查询时


SELECT COUNT

( * )

FROM FNRev 

WHERE A IN ()

AND B IN (  )

AND C = 1

AND D= 9

AND E= 0

GROUP BY (F)


当已经对A进行索引,但索引未生效时,有可能是其他字段的索引生效了,导致没有使用A索引

此时可以使用WITH (INDEX ( A ))指定索引


SELECT COUNT

( * )

FROM FNRev 

WITH (INDEX ( A ))

WHERE A IN ()

AND b IN (  )

AND c = 1

AND d= 9

AND e= 0

GROUP BY (f)

你可能感兴趣的:(SqlSrv数据库指定索引)