积极答复者
在執行計畫中看到一個sql沒使用到index,請問怎麼解釋這個現象?

问题
答案
-
在執行
SELECT distinct Orderno,location
FROM Mfsysproduct (NOLOCK)
WHERE Field4 = ''的時候,發現並未使用到索引。
在field4欄位上存在索引。
請問應該怎樣使這個查詢可以使用到索引?
If you haven't all the things you want,be grateful for the things you don't have that you didn't want.
Hi Wison,我记得以前你提过类似的问题
http://social.microsoft.com/Forums/zh-CN/sqlserverzhchs/thread/d0161feb-1ad2-40d1-b3ad-c77a10774377
有dba的职位吗- 已标记为答案 Hong-Gang Chen - MSFTModerator 2009年11月4日 6:53
全部回复
-
還有就是想下麵的sql,在a表上的custpono欄位和b表上的欄位beg03都是存在索引的,爲什麽查看執行計畫,都是沒有走索引的???
SELECT COUNT(DISTINCT b.mcid)
FROM sdordermaster a(NOLOCK),edibto850_main b(NOLOCK)
WHERE b.beg03 = a.custpono
If you haven't all the things you want,be grateful for the things you don't have that you didn't want. -
在執行
SELECT distinct Orderno,location
FROM Mfsysproduct (NOLOCK)
WHERE Field4 = ''的時候,發現並未使用到索引。
在field4欄位上存在索引。
請問應該怎樣使這個查詢可以使用到索引?
If you haven't all the things you want,be grateful for the things you don't have that you didn't want.因为输出列不在索引中,如果根据统计信息,field4=‘’的行数大于一定比例,就有可能不采用索引直接表扫描。
-
在執行
SELECT distinct Orderno,location
FROM Mfsysproduct (NOLOCK)
WHERE Field4 = ''的時候,發現並未使用到索引。
在field4欄位上存在索引。
請問應該怎樣使這個查詢可以使用到索引?
If you haven't all the things you want,be grateful for the things you don't have that you didn't want.
Hi Wison,我记得以前你提过类似的问题
http://social.microsoft.com/Forums/zh-CN/sqlserverzhchs/thread/d0161feb-1ad2-40d1-b3ad-c77a10774377
有dba的职位吗- 已标记为答案 Hong-Gang Chen - MSFTModerator 2009年11月4日 6:53