locked
Slow Running Query Vs. Long Running Qery RRS feed

  • Question

  • Hi All,

    Is there any difference between Slow Running Query and Long Running Query.

    Grateful to your views on this.

    Regards,

    Kalyan


    ----Learners Curiosity Never Ends----

    Tuesday, August 13, 2013 7:05 PM

Answers

  • Hi Kalyan,

    If your Query is expected to touch a lot of data and is expected to run for an extended duration - its a long running query.

    If you query is expected to completed quickly (due to the volume of data being touched of the nature of the query itself), but its running longer than expected - then its a slow running query.

    The Key differentiation is "expected" run time versus "actual" run time. Its also important to set realistic expectations on the "expected" run time. 

    This is a very generic/high level explanation. I guess you are asking this question because there is some query performance issue in your environment. Please do ask a more specific question and we can help further.


    Sanil Mhatre | Database Developer | MCTS | If you find my reply useful in any way, please vote it as helpful. If it has helped answer your question, please mark it as Answer. http://sqlwithsanil.com

    • Proposed as answer by Heidi-Duan Monday, August 26, 2013 8:17 AM
    • Marked as answer by Allen Li - MSFT Monday, August 26, 2013 9:04 AM
    Tuesday, August 13, 2013 7:16 PM

All replies

  • Hi Kalyan,

    If your Query is expected to touch a lot of data and is expected to run for an extended duration - its a long running query.

    If you query is expected to completed quickly (due to the volume of data being touched of the nature of the query itself), but its running longer than expected - then its a slow running query.

    The Key differentiation is "expected" run time versus "actual" run time. Its also important to set realistic expectations on the "expected" run time. 

    This is a very generic/high level explanation. I guess you are asking this question because there is some query performance issue in your environment. Please do ask a more specific question and we can help further.


    Sanil Mhatre | Database Developer | MCTS | If you find my reply useful in any way, please vote it as helpful. If it has helped answer your question, please mark it as Answer. http://sqlwithsanil.com

    • Proposed as answer by Heidi-Duan Monday, August 26, 2013 8:17 AM
    • Marked as answer by Allen Li - MSFT Monday, August 26, 2013 9:04 AM
    Tuesday, August 13, 2013 7:16 PM
  • I believe those are synonyms.  Generally, "slow" implies "long" - as in, a slower race car will take longer to finish the race.
    Tuesday, August 13, 2013 7:31 PM
    Answerer
  • Hi All,

    Is there any difference between Slow Running Query and Long Running Query.

    Grateful to your views on this.

    Regards,

    Kalyan


    ----Learners Curiosity Never Ends----

    Hello Kalyan,

    I agree with Scott.In database perspective both are dangerous. A slow running query will ultimately change into long runnig one due to blocking which it might face as it is unable to perform specified time within the threshold .


    Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers

    • Proposed as answer by Heidi-Duan Friday, August 16, 2013 1:57 AM
    Wednesday, August 14, 2013 5:00 AM
  • Hi Kalyan,

    Slow running query is a query which is executing beyond it's expected run time. The query state may be running however it may be running slow due to other factors like required resources not available, non optimal query plan is being used, more of table/index scan instead of index seek etc. etc.

    Long running query is a query which is running for a duration where it breaches it's threshold. Such queries are often in runnable or suspended state since either they wait for some external command like "Awaiting command"  or the process is not able to gain exclusive locks and wait indefinitely.Like for an example during index maintenance sometimes it keeps running since it could gain access to table for rebuild as that table may be in use and it keeps waiting for other resource to release locks. Such queries often becomes long running queries.

    Hope this helps!!


    Regards, Vishal Srivastava

    Wednesday, August 14, 2013 6:05 AM