SQL agent job stuck

  • Hi,

    I had a SQL agent job STUCK at a certain step and that step was using a SP PROC. Now, there was no blocking however high CPU due to some other queries, which I have noted. Now, when I recompiled the SP PROC( using USE DBNAME; GO EXECUTE SPPROC WITH RECOMPILE GO) which was being used by the same step, the Job moved to the next step and completed. Now, I don't fully understand why however are there any drawbacks of recompiling SP which is in use? is it possible,  it might impact inserts if that SP for example say doing inserts, and recompiled while being used. Does recompile only updates the statistics or something else. Please share your thoughts.

    Regards!

  • Thanks for posting your issue and hopefully someone will answer soon.

    This is an automated bump to increase visibility of your question.

  • Recompile forces SQL to recreate the query plan, even if one is already available in memory.

    That process may require updating stats if one of the tables in the query has had enough modifications to cause SQL to need to update the stats.  The stats update may be immediate or delayed, depending on other settings you made in SQL.

    There should be no harm from a recompile, other than a slight use of resources as SQL creates the plan.  In general, if recompile helps a run, use it, use it freely.  It's better to recompile when not needed than not to recompile when needed.

    SQL DBA,SQL Server MVP(07, 08, 09) "Money can't buy you happiness." Maybe so, but it can make your unhappiness a LOT more comfortable!

  • Further to what Scott has stated - the recompile will occur on the *next* use of the procedure/table and will not affect the currently running process.  It will not affect any currently running processes.

    Jeffrey Williams
    Problems are opportunities brilliantly disguised as insurmountable obstacles.

    How to post questions to get better answers faster
    Managing Transaction Logs

Viewing 4 posts - 1 through 3 (of 3 total)

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