減少聚集索引掃描成本如何降低下面提到查詢如何通過使用SQL查詢
DECLARE @PARAMVAL varchar(3)
set @PARAMVAL = 'CTD'
select * from MASTER_RECORD_TYPE where [email protected]
的聚集索引掃描的成本,如果我運行上面的查詢它顯示索引掃描99%
這裏下面我貼我的索引表:
請在這裏找到我下面的表特殊性
CREATE TABLE [dbo].[MASTER_RECORD_TYPE] ADD CONSTRAINT [PK_MASTER_REPORD_TYPE] PRIMARY KEY CLUSTERED
(
[Record_Type_Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 80) ON [PRIMARY]
GO
請告訴我如何降低索引掃描成本?
感謝您的及時回覆,你可以請指導我創建一個覆蓋非聚集索引,被列入該指數是什麼鍵你能幫助我的隊友對這個 – user1494292 2012-08-06 10:35:59
創建非聚集索引[MST_IDX_FOR_REC_TYPE ] ON [dbo]。[MASTER_RECORD_TYPE] ( \t [Record_Type_Code] ASC )WITH(PAD_INDEX = OFF,STATISTICS_NORECOMPUTE = OFF,SORT_IN_TEMPDB = OFF,IGNORE_DUP_KEY = OFF,DROP_EXISTING = OFF,ONLINE = OFF,ALLOW_ROW_LOCKS = ON,ALLOW_PAGE_LOCKS = ON)ON [PRIMARY ] GO現在索引掃描已經變成索引查找的100% – user1494292 2012-08-06 10:59:03
@ user1494292:好的 - 所以現在你有**索引尋找** - 這是最有效(最快)的方式來獲取(幾行的)數據 – 2012-08-06 11:04:55