I work on SQL server 2012 I face issue when add this statement it take 9 minutes to display 900 rows only
- SELECT fmat.Value as PLID,c.CodeType,
- COUNT(DISTINCT tr.PartID) [#partsHasCodes]
- into #partsHasCodes
- FROM Parts.TradeCodes tr WITH(NOLOCK)
- INNER JOIN Parts.Nop_Part pt WITH(NOLOCK) ON pt.PartID = tr.PartID
- INNER JOIN Parts.Nop_PartsFamilyAttribute fmat WITH(NOLOCK) ON fmat.PartFamilyID=pt.PartsFamilyID AND fmat.[Key]=20281007
- inner join #TempPlAndCodeType c on (c.CodeTypeId=tr.CodeTypeID) AND (c.PLID is null OR fmat.Value=c.PLID)
- GROUP BY fmat.Value,c.CodeType
without add this statement below
AND (c.PLID is null OR fmat.Value=c.PLID)
query take 3 minute to display 900 rows and after add
AND (c.PLID is null OR fmat.Value=c.PLID)
it take 9 minutes
Are there are any way to make query above to be optional without take too much time
PLID IS optional if it have value then get his value and code type
if PLID not have value then select data based on code type
so why it take too much time
ahmed elbarbaryPosted Aug 5, 2020, 11:33 PM
Navaneeth KrishnanPosted Aug 4, 2020, 10:17 PM