In the context of SQL, what does a runaway query mean?
Does it mean any query that runs wild when it takes too long? Or does it mean when it has some side-effects due to triggers?
Queries or updates that take longer than expected to execute can be caused by a variety of reasons. Slow-running queries can be caused by performance problems related to your network or the computer where SQL Server is running. Slow-running queries can also be caused by problems with your physical database design.
This query returns all queries in your Workspace with at least one run over the last 90 days, sorted by the average runtime per query run. You can use this query to identify queries in your Workspace consuming the most resources.
A runaway query is a query whose execution time is taking longer than the execution time estimated by the optimizer. Runaway queries can lead to using up all of your processor cycles or other resources during its execution.
It's a query that starts running and never comes back (for some value of "never").
Usually it means that the query isn't using an index it's supposed to, or using a bad join method, or a bad join order, or doing a bunch of string conversion/comparison.
It is possible to write SQL queries that take weeks/years to perform.
I apply this term specifically to a query that triggers, usually accidentally, behavior with runtime of unexpected complexity. If you expect a query to take O(n * m) (that is, a single join between two tables) and it takes O(n * n * m) then I would call it runaway, even if n * n * m is acceptably small in the instant case. More commonly this is experienced as a query expected to take O(log(n) * log(m)) taking O(n * n * m * m), which turns out to be unacceptably complex.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With