# query wait (s)

> Seconds a query may sit in the memory grant queue before failing; -1 derives the wait from the estimated cost.

Source: https://sqlly.app/sql-configuration/sql-server/query-wait
Last updated: 2026-11-30
License: Text and data [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) (credit SQLly, sqlly.app); code and SQL snippets [MIT](https://opensource.org/license/mit). [Details](https://sqlly.app/license).

**Default**

`-1 (auto)`

**Range**

-1, or 0 to 2147483647 seconds

**Restart needed**

No

**Default checked on**

SQL Server 2025

## What it does

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.

## Default value

`-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](https://sqlly.app/sql-configuration/sql-server), or check the [SQL Server manual](https://learn.microsoft.com/en-us/sql/database-engine/configure-windows/server-configuration-options-sql-server) for every option.

## Related SQL Server settings

- [`min memory per query (KB)` Smallest memory grant a query that sorts or hashes receives.](https://sqlly.app/sql-configuration/sql-server/min-memory-per-query)
- [`max server memory (MB)` Upper limit on the memory SQL Server's memory manager takes, buffer pool included.](https://sqlly.app/sql-configuration/sql-server/max-server-memory)
- [`query governor cost limit` Refuse to run queries whose estimated cost exceeds this; 0 disables.](https://sqlly.app/sql-configuration/sql-server/query-governor-cost-limit)

## Related on SQLly

- [Diagnosing a slow SQL query Performance guide](https://sqlly.app/sql-performance/slow-query)
