Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2003
    Posts
    15

    Unanswered: Slow SP on first execute

    Hi,

    I have a problem with certain SPs that take substantially longer the first time they are called. I am not sure how relevent it is but all of the procs in question use temporary tables.

    One of them also has a problem in the the execution plan appears to use the wrong index and I have to use an index hint to force it to use the correct one.

    Has anyone come across these type of problems?

    Many thanks
    David

  2. #2
    Join Date
    Jun 2003
    Posts
    269
    post ur problem sp,let us see.
    I love cursor,though I never use it.Cos' I dont want to misuse it.
    ----------------------------------------------

    ----cheers
    ----http://mallier.blogspot.com

  3. #3
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    First, please make sure the query performs better with the index hint.

    Second, when I write stored procedures I do my performance testing after executing DBCC FREEPROCAHE and DBCC DROPCLEANBUFFERS to ensure that it executes well on a "cold" server.

    Third, and I do not really care for this, but to get a consistent execution time (if this is your aim) every time you execute, add WITH RECOMPILE to the sp definition.

    Fourth, if your query runs unacceptablly long on a "cold" server, you need to tune the query as much as possible. People here love to rewrite code, so post your query and the execution plan and where the indices are placed and some one may help you out. See Brett's sticky at the top of the forum.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •