osql batch taking long longgg time

  • hi,

    trying to understand whats going on and was hoping someone could help.

    I have 10 scripts to run. Doing them 1 by 1 it takes less than a second for each to run. speeds though no problems.

    If i put them into a osql batch its gets part way though and now just crawling along.. I have SP_WhoIsActive and running that its on the same query (A simple update single row)

    And its just not moving.. the cpu total is just rising and rising, reads have gone into the millions! and status is suspended and its a wait on pageiolatch_ex (few mins ago it was pageiolatch_sh)

    I know osql isn't a preferred choice but from the quick read around i saw its only because its limited in options compared to sqlcmd so didn't think that would factor..

    the osql lines are -

    osql -E -S server -d db -i "C:\temp\stage1.sql" -o "C:\temp\1.ans"

    Just thought is it running all of the scripts at once? Ive just got ans files created for scripts that happen after this update!

    Any ideas?

  • Chances are the issue has nothing to do with osql but I am compelled to say it anyway, switch to using sqlcmd.exe, osql.exe has been a deprecated feature since SQL 2005 🙂

    pageiolatch_ex means a query in the script needs data from disk. You said the scripts ran in seconds when run 1 by 1. Was that is an SSMS query window? And was that against the same database with the same amount of data on a server with the same amount of activity?

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

  • Might be worth checking sys.dm_os_waiting_tasks and sys.dm_tran_lock

    Regards

  • hi!

    yes i ran them i ssms.. it was against the same database / machine seemed to get stuck but did finish eventually.. nothing else was happening on the box.

    Ill see what happens with sqlcmd tomorrow, Do you know if osql was running all the scripts at the same time or it does one then proceeds to the next.

    thanks

  • Sorry Paul missed your post!

    ill take a look at them when i do it again.. hopefully help track it down some more...

    guessing it has to be some sort of locking issue..

    Thanks

  • n00bDBA (10/10/2012)


    Do you know if osql was running all the scripts at the same time or it does one then proceeds to the next.

    Separate calls to the exe will constitute a separate session to the database. Inside each script the existence of a GO will separate batches within the same session.

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

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

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