我有這個疑問,實際上它是與此類似,這是爲測試目的:TOP性能問題
SELECT
[Distinct1].[ProspectID] AS [ProspectID]
FROM (SELECT DISTINCT
[Limit1].[ProspectID] AS [ProspectID]
FROM (SELECT TOP 10
[Extent1].[ProspectID] AS [ProspectID]
FROM [sqlsolvent].[crm_SearchTable] AS [Extent1]
WHERE ([Extent1].[CP_Name] LIKE '%dsd%' ESCAPE N'~')
) AS [Limit1]
) AS [Distinct1]
這是它的執行計劃:
當我刪除TOP 10
從查詢我得到這個執行計劃:
沒有TOP 10
的第二個執行計劃速度提高了2倍,有人能解釋爲什麼TOP會如此改變執行計劃,爲什麼它會如此慢?即使查詢沒有返回任何結果,也不應該只將頂端添加到結果集中,爲什麼查詢在返回時什麼都不會影響性能?
[TOP(以及爲什麼)TOP影響執行計劃?](http://dba.stackexchange.com/questions/24832/how-and-why-does-top-impact-an-execution-plan/ 24848#24848) –