Why same stored procedure getting slower ??

  • Hi,

    Anyone faces this issue, of why the same SP in SQL2k SP4

    when initially run, is fast and okay.

    However, when i run it the second time or more, it just

    keep getting slower from 30seconds to 2minutes.

    Anyone know who or how it is happening.

    My SP just using a cursor and even when

    I change it to using loop, it does not

    help.

    Thank you

  • Unfortunately, without seeing the code, knowing if this process is the only item running on the server, etc. it is hard to guess as to why



    Good Hunting!

    AJ Ahrens


    webmaster@kritter.net

  • Hi,

    Actually, my SP just having 02 cursor

    where the outer cursor will pass some

    info to the inner cursor to process

    and update some data.

    I have modify the outer cursor into

    using loop as my testing show that

    changing the inner cursor to loop

    does not have any speed improvement.

    Or maybe it does have some improvement

    as subsequence running of the same SP

    will deteriorate my system, causing the

    same SP to slow down to maybe 2 or 3 minutes.

    Anything to look out for.

    Thank you

  • Could you post your actual code (maybe changing some names)?

    Actually, my SP just having 02 cursor

    where the outer cursor will pass some

    info to the inner cursor to process

    and update some data.

     

    is still too generic and maybe the cursors can be thrown out all together.

    Does it help storing your stored procedures with the option WITH RECOMPILE?

  • Is your inner cursor performing an update? What is the sp doing?

  • Since you didn't post the code snipet, one of the first things I would check is to make sure that you DEALLOCATE the cursors after you CLOSE them. 

Viewing 6 posts - 1 through 5 (of 5 total)

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