Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2002
    Posts
    2

    Exclamation Unanswered: Extremly bad performance Stored Procedures

    The last few days my sqlserver executes stored procedures badly.
    When I run the Query Analyzer to execute a certain stored procedure it takes more than 2 minutes to execute the procedure. When I copy the contents of de SP to Query analyser to run it as an sql statement it find's the results within a second.
    This behavior dissapear's after a while and comes back randomly.
    I had the problem Friday afternoon then tuesday and now again.
    Between these day's my sqlserver works fine.
    Can anybody please help me with this problem.

  2. #2
    Join Date
    Feb 2002
    Posts
    2,232
    Have you tried using the "with recompile" option ? Your query plan is probably based on an outdated data distribution or schema. Running the "with recompile" option will regenerate the query plan. Also, are you parameters to the stored procedure vary enough that the execution plans change ? Do a comparison in query analyzer - using show execution plan.

  3. #3
    Join Date
    Oct 2002
    Posts
    2
    I was able to elimante the problem by altering de SP.
    In the SP there where more than 4 joins to the same table.
    When I made a user defined function and replaced those joins with this function, it all works fine.

    But one question remains. How is it possible that the query analyser didn't have problems with the joins but de SP did have?

  4. #4
    Join Date
    Feb 2002
    Posts
    2,232
    Did you try the recompile ? Sometimes, if your table(s) involved in the query change enough - the query plan needs to change as well. When you run it in query analyzer, the query plan is generated dynamically. For the sp, it could still be using the original query plan when you created it. That is why I suggested to run the 2 in query analyzer with the "show execution plan".

Posting Permissions

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