Home Forums SQL Server 2008 SQL Server 2008 - General facing serious performance issues, please see the scenario below need urgent help - Please chk the code below RE: facing serious performance issues, please see the scenario below need urgent help - Please chk the code below

  • also, my rule of thumb is that any @TableVariable with more than a few hundred rows should be a temp table instead, to allow the system to automatically do things like generate statistics;

    From the estimated # of rows from the estimated execution plans i see 200K+ rows for every query in there.

    i see a missing index suggestions for every query in the plan as well.

    Since this was not an actual execution plan, i'm concerned that the high number of estimated rows might be due to bad statistics.

    I see Non-SARG-able items that force a table scan, like:

    AND(DATEDIFF(DD,AF.FCT_DT,AF.LST_MFS_EVNT_DT)>=60)

    AND(DATEDIFF(DD,AF.FCT_DT,AF.LST_MFS_EVNT_DT)>=30)

    since they are all going into the same table with the same structure, i'd change this to be a CTE with UNION ALL isntead of a @TableVariable.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!