我有两个关于提高存储过程性能的问题:
1) 在 SELECT 子句中:
,CASE WHEN vatcs.CashDeskId IN (1293,1296,1295) THEN 1 ELSE 0 END --Кассы-метро
,CASE WHEN vatcs.CashDeskId IN (21,994,1137,1150,1162,1163,1282,1314,1327,1328) THEN 1 ELSE 0 END --Кассы-остальные
,CASE WHEN vatcs.CashDeskId IN (988) THEN 1 ELSE 0 END --Портал 2.0
,CASE WHEN vatcs.CashDeskId IN (1089,1088,122,1085,1087,1084,1086,270) THEN 1 ELSE 0 END --Евросеть
,CASE WHEN ISNULL(vatcs.CashdeskID, 0) NOT IN (1293,1296,1295,21,994,1137,1150,1162,1163,1282,1314,1327,1328,988,1089,1088,122,1085,1087,1084,1086,270)
有没有可能加快速度?
2) 在 WHERE 子句中:
WHERE vatcs.SoldDate >= @beginDate
AND vatcs.SoldDate < DATEADD(DAY, 1, @endDate)
我不确定它是否是 sargable,如果不是,我怎样才能使它成为 sargable?