Selecting into a view with no where clause is much faster that adding a where clause
Pulling my hair out with this. The following query returns in 9 seconds if the where clause is omitted, but takes minutes with a where clause. A select all into a temp table and issuing the where clause on the temp table takes ~22secs.
SELECT
Style AS Item
,Color
,[Size]
,QtyAvailable
,UPC
,Status
,DateAvailable AS EstimatedAvailDate
FROM
[LAN_VW_B2B_Upcs]
WHERE
ItemGroup = 'FG'
AND ProductSegment IN ('BASIC', 'CORE', 'POS')
AND Brand NOT IN ('IL')
SELECT
Style AS Item
,Color
,[Size]
,QtyAvailable
,UPC
,Status
,DateAvailable AS EstimatedAvailDate
FROM
[LAN_VW_B2B_Upcs]
WHERE
ItemGroup = 'FG'
AND ProductSegment IN ('BASIC', 'CORE', 'POS')
AND Brand NOT IN ('IL')
Comments