Configure the query wait (server configuration option)
Applies to:
SQL Server
This topic describes how to configure the query wait server configuration option in SQL Server by using SQL Server Management Studio or Transact-SQL. Memory-intensive queries (such as those involving sorting and hashing) are queued when there is not enough memory available to run the query. The query wait option specifies the time, in seconds (from 0 through 2147483647), that a query waits for resources before it times out. The default value for this option is -1. This means the time-out is calculated as 25 times the estimated query cost.
Important
A transaction that contains the waiting query might hold locks while the query waits for memory. In rare situations, it is possible for an undetectable deadlock to occur. Decreasing the query wait time lowers the probability of such deadlocks. Eventually, a waiting query will be terminated and the transaction locks released. However, increasing the maximum wait time may increase the amount of time for the query to be terminated. Changes to this option are not recommended.
In This Topic
Before you begin:
To configure the query wait option, using:
Follow Up: After you configure the query wait option
Before You Begin
Recommendations
- This option is an advanced option and should be changed only by an experienced database administrator or certified SQL Server professional.
Security
Permissions
Execute permissions on sp_configure with no parameters or with only the first parameter are granted to all users by default. To execute sp_configure with both parameters to change a configuration option or to run the RECONFIGURE statement, a user must be granted the ALTER SETTINGS server-level permission. The ALTER SETTINGS permission is implicitly held by the sysadmin and serveradmin fixed server roles.
Using SQL Server Management Studio
To configure the query wait option
In Object Explorer, right-click a server and select Properties.
Click the Advanced node.
Under Parallelism, type the desired value for the query wait option.
Using Transact-SQL
To configure the query wait option
Connect to the Database Engine.
From the Standard bar, click New Query.
Copy and paste the following example into the query window and click Execute. This example shows how to use sp_configure to set the value of the
query wait
option to7500
seconds.
USE AdventureWorks2022;
GO
EXEC sp_configure 'show advanced options', 1;
GO
RECONFIGURE ;
GO
EXEC sp_configure 'query wait', 7500 ;
GO
RECONFIGURE;
GO
For more information, see Server Configuration Options (SQL Server).
Follow Up: After you configure the query wait option
The setting takes effect immediately without restarting the server.
See Also
RECONFIGURE (Transact-SQL)
Server Configuration Options (SQL Server)
sp_configure (Transact-SQL)