query wait (s)
Seconds a query may sit in the memory grant queue before failing; -1 derives the wait from the estimated cost.
- デフォルト
-1 (auto)- Range
- -1, or 0 to 2147483647 seconds
- Restart needed
- いいえ
- Default checked on
- SQL Server 2025
何ができるか
It bounds the RESOURCE_SEMAPHORE wait of queries that need a sort or hash grant and cannot get one. The default -1 computes the timeout as 25 times the estimated query cost, and at the deadline the query fails with error 8645 and must be rerun. Lock waits follow LOCK_TIMEOUT instead; this option never touches them.
デフォルト値
-1 (auto). -1, 25 times the estimated query cost (SQL Server 2025).
Check the current value
SELECT name, value, value_in_use, minimum, maximum, is_dynamic, is_advanced FROM sys.configurations WHERE name = 'query wait (s)'; -- EXEC sp_configure 'query wait (s)'; also works, but only while show advanced options is 1; -- otherwise it fails with Msg 15123 because this is an advanced option.
Change it
EXEC sp_configure 'show advanced options', 1; RECONFIGURE; EXEC sp_configure 'query wait (s)', 300; RECONFIGURE;
No restart: it takes effect when RECONFIGURE runs (sys.configurations.is_dynamic = 1). It is an advanced option, so show advanced options must be on to change it.
When to change it
Once grant queueing is diagnosed, use it as a policy: a low value fails runaway requests fast instead of letting them hold connections and locks, and a high value lets genuine reports wait out a busy window. Fix the memory sizing first, because this only trades waiting against failing.
What can go wrong
Long waits hide a memory shortage rather than fix it: queries pile up in RESOURCE_SEMAPHORE, callers time out on their side while the server-side locks stay held. Set it too low and legitimate reports start dying with error 8645 during peaks.
Questions about query wait (s)
What is the default value of query wait (s) in SQL Server?
-1 (auto). -1, 25 times the estimated query cost (SQL Server 2025).
Does changing query wait (s) require a restart?
No. No restart: it takes effect when RECONFIGURE runs (sys.configurations.is_dynamic = 1). It is an advanced option, so show advanced options must be on to change it.
When should I change query wait (s)?
Once grant queueing is diagnosed, use it as a policy: a low value fails runaway requests fast instead of letting them hold connections and locks, and a high value lets genuine reports wait out a busy window. Fix the memory sizing first, because this only trades waiting against failing.
Back to all SQL Server settings, or check the SQL Server manual for every option.
Related on SQLly
Check query wait (s) on your own server
SQLly runs the query above against SQL Server and the other engines in this reference, from one desktop app on macOS, Windows and Linux.
このページのテキストとデータ: CC BY 4.0、出典は SQLly (sqlly.app) と明記してください。 コードと SQL スニペット: MIT. ライセンスの詳細