Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: set default for large_full_scan_rows to 0 #131040

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/generated/settings/settings-for-tenants.txt
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ This session variable default should now be configured using ALTER ROLE... SET:
sql.defaults.default_int_size integer 8 "the size, in bytes, of an INT type
This cluster setting is being kept to preserve backwards-compatibility.
This session variable default should now be configured using ALTER ROLE... SET: https://www.cockroachlabs.com/docs/stable/alter-role.html" application
sql.defaults.disallow_full_table_scans.enabled boolean false "setting to true rejects queries that have planned a full table scan
sql.defaults.disallow_full_table_scans.enabled boolean false "setting to true rejects queries that have planned a full table scan; set large_full_scan_rows > 0 to allow small full table scans estimated to read fewer than large_full_scan_rows
This cluster setting is being kept to preserve backwards-compatibility.
This session variable default should now be configured using ALTER ROLE... SET: https://www.cockroachlabs.com/docs/stable/alter-role.html" application
sql.defaults.distsql enumeration auto "default distributed SQL execution mode [off = 0, auto = 1, on = 2, always = 3]
Expand Down Expand Up @@ -229,7 +229,7 @@ This session variable default should now be configured using ALTER ROLE... SET:
sql.defaults.intervalstyle enumeration postgres "default value for IntervalStyle session setting [postgres = 0, iso_8601 = 1, sql_standard = 2]
This cluster setting is being kept to preserve backwards-compatibility.
This session variable default should now be configured using ALTER ROLE... SET: https://www.cockroachlabs.com/docs/stable/alter-role.html" application
sql.defaults.large_full_scan_rows float 1000 "default value for large_full_scan_rows session setting which determines the maximum table size allowed for a full scan when disallow_full_table_scans is set to true
sql.defaults.large_full_scan_rows float 0 "default value for large_full_scan_rows session variable which determines the table size at which full scans are considered large and disallowed when disallow_full_table_scans is set to true; set to 0 to reject all full table or full index scans when disallow_full_table_scans is true
This cluster setting is being kept to preserve backwards-compatibility.
This session variable default should now be configured using ALTER ROLE... SET: https://www.cockroachlabs.com/docs/stable/alter-role.html" application
sql.defaults.locality_optimized_partitioned_index_scan.enabled boolean true "default value for locality_optimized_partitioned_index_scan session setting; enables searching for rows in the current region before searching remote regions
Expand Down
4 changes: 2 additions & 2 deletions docs/generated/settings/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
<tr><td><div id="setting-sql-defaults-datestyle" class="anchored"><code>sql.defaults.datestyle</code></div></td><td>enumeration</td><td><code>iso, mdy</code></td><td>default value for DateStyle session setting [iso, mdy = 0, iso, dmy = 1, iso, ymd = 2]<br/>This cluster setting is being kept to preserve backwards-compatibility.<br/>This session variable default should now be configured using <a href="alter-role.html"><code>ALTER ROLE... SET</code></a></td><td>Serverless/Dedicated/Self-Hosted</td></tr>
<tr><td><div id="setting-sql-defaults-default-hash-sharded-index-bucket-count" class="anchored"><code>sql.defaults.default_hash_sharded_index_bucket_count</code></div></td><td>integer</td><td><code>16</code></td><td>used as bucket count if bucket count is not specified in hash sharded index definition<br/>This cluster setting is being kept to preserve backwards-compatibility.<br/>This session variable default should now be configured using <a href="alter-role.html"><code>ALTER ROLE... SET</code></a></td><td>Serverless/Dedicated/Self-Hosted</td></tr>
<tr><td><div id="setting-sql-defaults-default-int-size" class="anchored"><code>sql.defaults.default_int_size</code></div></td><td>integer</td><td><code>8</code></td><td>the size, in bytes, of an INT type<br/>This cluster setting is being kept to preserve backwards-compatibility.<br/>This session variable default should now be configured using <a href="alter-role.html"><code>ALTER ROLE... SET</code></a></td><td>Serverless/Dedicated/Self-Hosted</td></tr>
<tr><td><div id="setting-sql-defaults-disallow-full-table-scans-enabled" class="anchored"><code>sql.defaults.disallow_full_table_scans.enabled</code></div></td><td>boolean</td><td><code>false</code></td><td>setting to true rejects queries that have planned a full table scan<br/>This cluster setting is being kept to preserve backwards-compatibility.<br/>This session variable default should now be configured using <a href="alter-role.html"><code>ALTER ROLE... SET</code></a></td><td>Serverless/Dedicated/Self-Hosted</td></tr>
<tr><td><div id="setting-sql-defaults-disallow-full-table-scans-enabled" class="anchored"><code>sql.defaults.disallow_full_table_scans.enabled</code></div></td><td>boolean</td><td><code>false</code></td><td>setting to true rejects queries that have planned a full table scan; set large_full_scan_rows &gt; 0 to allow small full table scans estimated to read fewer than large_full_scan_rows<br/>This cluster setting is being kept to preserve backwards-compatibility.<br/>This session variable default should now be configured using <a href="alter-role.html"><code>ALTER ROLE... SET</code></a></td><td>Serverless/Dedicated/Self-Hosted</td></tr>
<tr><td><div id="setting-sql-defaults-distsql" class="anchored"><code>sql.defaults.distsql</code></div></td><td>enumeration</td><td><code>auto</code></td><td>default distributed SQL execution mode [off = 0, auto = 1, on = 2, always = 3]<br/>This cluster setting is being kept to preserve backwards-compatibility.<br/>This session variable default should now be configured using <a href="alter-role.html"><code>ALTER ROLE... SET</code></a></td><td>Serverless/Dedicated/Self-Hosted</td></tr>
<tr><td><div id="setting-sql-defaults-experimental-alter-column-type-enabled" class="anchored"><code>sql.defaults.experimental_alter_column_type.enabled</code></div></td><td>boolean</td><td><code>false</code></td><td>default value for experimental_alter_column_type session setting; enables the use of ALTER COLUMN TYPE for general conversions<br/>This cluster setting is being kept to preserve backwards-compatibility.<br/>This session variable default should now be configured using <a href="alter-role.html"><code>ALTER ROLE... SET</code></a></td><td>Serverless/Dedicated/Self-Hosted</td></tr>
<tr><td><div id="setting-sql-defaults-experimental-distsql-planning" class="anchored"><code>sql.defaults.experimental_distsql_planning</code></div></td><td>enumeration</td><td><code>off</code></td><td>default experimental_distsql_planning mode; enables experimental opt-driven DistSQL planning [off = 0, on = 1]<br/>This cluster setting is being kept to preserve backwards-compatibility.<br/>This session variable default should now be configured using <a href="alter-role.html"><code>ALTER ROLE... SET</code></a></td><td>Serverless/Dedicated/Self-Hosted</td></tr>
Expand All @@ -230,7 +230,7 @@
<tr><td><div id="setting-sql-defaults-implicit-select-for-update-enabled" class="anchored"><code>sql.defaults.implicit_select_for_update.enabled</code></div></td><td>boolean</td><td><code>true</code></td><td>default value for enable_implicit_select_for_update session setting; enables FOR UPDATE locking during the row-fetch phase of mutation statements<br/>This cluster setting is being kept to preserve backwards-compatibility.<br/>This session variable default should now be configured using <a href="alter-role.html"><code>ALTER ROLE... SET</code></a></td><td>Serverless/Dedicated/Self-Hosted</td></tr>
<tr><td><div id="setting-sql-defaults-insert-fast-path-enabled" class="anchored"><code>sql.defaults.insert_fast_path.enabled</code></div></td><td>boolean</td><td><code>true</code></td><td>default value for enable_insert_fast_path session setting; enables a specialized insert path<br/>This cluster setting is being kept to preserve backwards-compatibility.<br/>This session variable default should now be configured using <a href="alter-role.html"><code>ALTER ROLE... SET</code></a></td><td>Serverless/Dedicated/Self-Hosted</td></tr>
<tr><td><div id="setting-sql-defaults-intervalstyle" class="anchored"><code>sql.defaults.intervalstyle</code></div></td><td>enumeration</td><td><code>postgres</code></td><td>default value for IntervalStyle session setting [postgres = 0, iso_8601 = 1, sql_standard = 2]<br/>This cluster setting is being kept to preserve backwards-compatibility.<br/>This session variable default should now be configured using <a href="alter-role.html"><code>ALTER ROLE... SET</code></a></td><td>Serverless/Dedicated/Self-Hosted</td></tr>
<tr><td><div id="setting-sql-defaults-large-full-scan-rows" class="anchored"><code>sql.defaults.large_full_scan_rows</code></div></td><td>float</td><td><code>1000</code></td><td>default value for large_full_scan_rows session setting which determines the maximum table size allowed for a full scan when disallow_full_table_scans is set to true<br/>This cluster setting is being kept to preserve backwards-compatibility.<br/>This session variable default should now be configured using <a href="alter-role.html"><code>ALTER ROLE... SET</code></a></td><td>Serverless/Dedicated/Self-Hosted</td></tr>
<tr><td><div id="setting-sql-defaults-large-full-scan-rows" class="anchored"><code>sql.defaults.large_full_scan_rows</code></div></td><td>float</td><td><code>0</code></td><td>default value for large_full_scan_rows session variable which determines the table size at which full scans are considered large and disallowed when disallow_full_table_scans is set to true; set to 0 to reject all full table or full index scans when disallow_full_table_scans is true<br/>This cluster setting is being kept to preserve backwards-compatibility.<br/>This session variable default should now be configured using <a href="alter-role.html"><code>ALTER ROLE... SET</code></a></td><td>Serverless/Dedicated/Self-Hosted</td></tr>
<tr><td><div id="setting-sql-defaults-locality-optimized-partitioned-index-scan-enabled" class="anchored"><code>sql.defaults.locality_optimized_partitioned_index_scan.enabled</code></div></td><td>boolean</td><td><code>true</code></td><td>default value for locality_optimized_partitioned_index_scan session setting; enables searching for rows in the current region before searching remote regions<br/>This cluster setting is being kept to preserve backwards-compatibility.<br/>This session variable default should now be configured using <a href="alter-role.html"><code>ALTER ROLE... SET</code></a></td><td>Serverless/Dedicated/Self-Hosted</td></tr>
<tr><td><div id="setting-sql-defaults-lock-timeout" class="anchored"><code>sql.defaults.lock_timeout</code></div></td><td>duration</td><td><code>0s</code></td><td>default value for the lock_timeout; default value for the lock_timeout session setting; controls the duration a query is permitted to wait while attempting to acquire a lock on a key or while blocking on an existing lock in order to perform a non-locking read on a key; if set to 0, there is no timeout<br/>This cluster setting is being kept to preserve backwards-compatibility.<br/>This session variable default should now be configured using <a href="alter-role.html"><code>ALTER ROLE... SET</code></a></td><td>Serverless/Dedicated/Self-Hosted</td></tr>
<tr><td><div id="setting-sql-defaults-on-update-rehome-row-enabled" class="anchored"><code>sql.defaults.on_update_rehome_row.enabled</code></div></td><td>boolean</td><td><code>true</code></td><td>default value for on_update_rehome_row; enables ON UPDATE rehome_row() expressions to trigger on updates<br/>This cluster setting is being kept to preserve backwards-compatibility.<br/>This session variable default should now be configured using <a href="alter-role.html"><code>ALTER ROLE... SET</code></a></td><td>Serverless/Dedicated/Self-Hosted</td></tr>
Expand Down
13 changes: 8 additions & 5 deletions pkg/sql/exec_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,9 @@ var SerialNormalizationMode = settings.RegisterEnumSetting(
var disallowFullTableScans = settings.RegisterBoolSetting(
settings.ApplicationLevel,
`sql.defaults.disallow_full_table_scans.enabled`,
"setting to true rejects queries that have planned a full table scan",
"setting to true rejects queries that have planned a full table scan; set "+
"large_full_scan_rows > 0 to allow small full table scans estimated to "+
"read fewer than large_full_scan_rows",
false,
settings.WithPublic)

Expand Down Expand Up @@ -709,10 +711,11 @@ var txnRowsReadErr = settings.RegisterIntSetting(
var largeFullScanRows = settings.RegisterFloatSetting(
settings.ApplicationLevel,
"sql.defaults.large_full_scan_rows",
"default value for large_full_scan_rows session setting which determines "+
"the maximum table size allowed for a full scan when disallow_full_table_scans "+
"is set to true",
1000.0,
"default value for large_full_scan_rows session variable which determines "+
"the table size at which full scans are considered large and disallowed "+
"when disallow_full_table_scans is set to true; set to 0 to reject all "+
"full table or full index scans when disallow_full_table_scans is true",
0,
settings.WithPublic)

var costScansWithDefaultColSize = settings.RegisterBoolSetting(
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/logictest/testdata/logic_test/information_schema
Original file line number Diff line number Diff line change
Expand Up @@ -6273,7 +6273,7 @@ is_superuser on
join_reader_index_join_strategy_batch_size 4.0 MiB
join_reader_no_ordering_strategy_batch_size 2.0 MiB
join_reader_ordering_strategy_batch_size 100 KiB
large_full_scan_rows 1000
large_full_scan_rows 0
lc_collate C.UTF-8
lc_ctype C.UTF-8
lc_messages C.UTF-8
Expand Down
4 changes: 2 additions & 2 deletions pkg/sql/logictest/testdata/logic_test/pg_catalog
Original file line number Diff line number Diff line change
Expand Up @@ -2918,7 +2918,7 @@ is_superuser on N
join_reader_index_join_strategy_batch_size 4.0 MiB NULL NULL NULL string
join_reader_no_ordering_strategy_batch_size 2.0 MiB NULL NULL NULL string
join_reader_ordering_strategy_batch_size 100 KiB NULL NULL NULL string
large_full_scan_rows 1000 NULL NULL NULL string
large_full_scan_rows 0 NULL NULL NULL string
lc_collate C.UTF-8 NULL NULL NULL string
lc_ctype C.UTF-8 NULL NULL NULL string
lc_messages C.UTF-8 NULL NULL NULL string
Expand Down Expand Up @@ -3110,7 +3110,7 @@ is_superuser on N
join_reader_index_join_strategy_batch_size 4.0 MiB NULL user NULL 4.0 MiB 4.0 MiB
join_reader_no_ordering_strategy_batch_size 2.0 MiB NULL user NULL 2.0 MiB 2.0 MiB
join_reader_ordering_strategy_batch_size 100 KiB NULL user NULL 100 KiB 100 KiB
large_full_scan_rows 1000 NULL user NULL 1000 1000
large_full_scan_rows 0 NULL user NULL 0 0
lc_collate C.UTF-8 NULL user NULL C.UTF-8 C.UTF-8
lc_ctype C.UTF-8 NULL user NULL C.UTF-8 C.UTF-8
lc_messages C.UTF-8 NULL user NULL C.UTF-8 C.UTF-8
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/logictest/testdata/logic_test/show_source
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ is_superuser on
join_reader_index_join_strategy_batch_size 4.0 MiB
join_reader_no_ordering_strategy_batch_size 2.0 MiB
join_reader_ordering_strategy_batch_size 100 KiB
large_full_scan_rows 1000
large_full_scan_rows 0
lc_collate C.UTF-8
lc_ctype C.UTF-8
lc_messages C.UTF-8
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/opt/exec/execbuilder/relational.go
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ func (b *Builder) buildScan(scan *memo.ScanExpr) (_ execPlan, outputCols colOrdM
relProps := scan.Relational()
stats := relProps.Statistics()
if !tab.IsVirtualTable() && isUnfiltered {
large := !stats.Available || stats.RowCount > b.evalCtx.SessionData().LargeFullScanRows
large := !stats.Available || stats.RowCount >= b.evalCtx.SessionData().LargeFullScanRows
if scan.Index == cat.PrimaryIndex {
b.flags.Set(exec.PlanFlagContainsFullTableScan)
if large {
Expand Down
Loading