Need to avoid table spool in view

  • hi

    i have created view which is running slow,i saw execution plan and it seems table spool takes 50%,every other thing is fine.

    How to avoid table spool,any advice

    Thanks

  • Please attach the actual execution plan in a new message (.sqlplan).

  • Are you using a recursive CTE? In that case, the table spool is inevitable.


    N 56°04'39.16"
    E 12°55'05.25"

  • Table spools are generally optimisations so that the execution engine doesn't have to go back and recalculate things.

    Sure the costs are correct and the table spool really is the problem?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • hi

    i am seeing table spool 50% and keylookup 69%

    so i think this both can be problem

  • Please post table definitions, index definitions and execution plan, as per http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • hi

    i cant put my all execution plan,all oher field is 0%,except table spool and key lookup.

    i dont understand how to increase my time

  • daveriya (8/3/2011)


    hi

    i cant put my all execution plan,all oher field is 0%,except table spool and key lookup.

    i dont understand how to increase my time

    daveriya,

    Without any additional information, the best suggestion we could probably give you is to add "WITH SCHEMA BINDING" to the view definition and make sure you don't have a recursive CTE in the code.

    If you really want help on this, the only way folks can figure out what's wrong is to see the Actual Execution Plan. See the article that Gila Monster provided a link for to learn how to save a copy of the execution plan and then attach it to your next post. Posting the code for the View would be extremely helpful, as well.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • hi

    the thing is i cannot show my data ,its confidential ,i can show my execution plan,but when i save it comes with query,is there any way i can show only my execution plan

  • daveriya (8/4/2011)


    hi

    the thing is i cannot show my data ,its confidential ,i can show my execution plan,but when i save it comes with query,is there any way i can show only my execution plan

    We can understand that. Show SAMPLE data. Juste make sure if covers all your needs in the query and then show the required output from that sample data.

    That way we all speak the same language and see the same thing > math & logic.

  • hi

    i am attaching my query part in doc.plz see it and reply me asap

  • GilaMonster (8/3/2011)


    Please post table definitions, index definitions and execution plan, as per http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

    Nope, read the previous and do that, we can't help without ALL that info.

  • if you dont want to help,dont comment

  • daveriya (8/4/2011)


    if you dont want to help,dont comment

    If intend to treat us that way you better find another forum to get help.

  • daveriya (8/4/2011)


    if you dont want to help,dont comment

    If you want help, read the article that explains what we need to solve this kind of problem. Screenshot of execution plan != execution plan

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 15 posts - 1 through 15 (of 18 total)

You must be logged in to reply to this topic. Login to reply