query governor cost limit
Refuse to run queries whose estimated cost exceeds this; 0 disables.
- 默认
0 (off)- Range
- 0 to 2147483647
- Restart needed
- 否
- Default checked on
- SQL Server 2025
作用
The check uses the optimizer's estimated cost before execution, so it is not a time limit and depends on estimate quality. A session can override it with SET QUERY_GOVERNOR_COST_LIMIT.
默认值
0 (off). 0 (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 governor cost limit'; -- EXEC sp_configure 'query governor cost limit'; 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 governor cost limit', 3000; 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
Rarely: Resource Governor gives finer control. Possibly on ad hoc reporting servers to reject runaway cross joins.
What can go wrong
Legitimate queries with inflated estimates are rejected outright.
Questions about query governor cost limit
What is the default value of query governor cost limit in SQL Server?
0 (off). 0 (SQL Server 2025).
Does changing query governor cost limit 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 governor cost limit?
Rarely: Resource Governor gives finer control. Possibly on ad hoc reporting servers to reject runaway cross joins.
Back to all SQL Server settings, or check the SQL Server manual for every option.
Related on SQLly
Check query governor cost limit 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.