From 5830d7035cdfab0107c546cc3b9ee956e6a7b150 Mon Sep 17 00:00:00 2001 From: wenyihu3 Date: Thu, 4 Aug 2022 07:35:07 -0400 Subject: [PATCH] sql: setting to disable NotVisible index feature Prior to this commit, not visible indexes were always ignored by the optimizer unless it is explicitly selected with index hinting or used for constraint check. This commit adds a session variable along with a cluster setting to control whether the optimizer can still choose to use not visible indexes for the query plan. Note that even if the the session variable is enabled and optimizer can choose to use not visible indexes, not visible indexes remain as not visible in index descriptors. Cluster setting: `sql.defaults.optimizer_use_not_visible_indexes.enabled` Session setting: `optimizer_use_not_visible_indexes` By default, the setting is disabled, meaning not visible index will be properly ignored. When the setting is enabled, optimizer treats not visible indexes as they are visible and can choose to use them for query plan. Assists: https://github.com/cockroachdb/cockroach/issues/82363 Release note (sql change): Session setting `optimizer_use_not_visible_indexes` and cluster setting `sql.defaults.optimizer_use_not_visible_indexes.enabled` can be used to disable not visible index feature. When they are enabled, optimizer treats not visible indexes as they are visible and can choose to use them for query plan. By default, they are disabled. --- .../settings/settings-for-tenants.txt | 3 ++ docs/generated/settings/settings.html | 1 + .../testdata/explain-bundle/bundle/env.sql | 2 + pkg/settings/registry.go | 1 + pkg/sql/exec_util.go | 19 +++++++ pkg/sql/explain_bundle.go | 1 + .../testdata/logic_test/information_schema | 3 +- .../logictest/testdata/logic_test/pg_catalog | 3 ++ .../logictest/testdata/logic_test/show_source | 3 +- .../opt/exec/execbuilder/testdata/explain_env | 26 +++++----- .../execbuilder/testdata/not_visible_index | 52 +++++++++++++++++++ pkg/sql/opt/memo/memo.go | 3 ++ pkg/sql/opt/memo/memo_test.go | 6 +++ pkg/sql/opt/xform/scan_index_iter.go | 3 +- .../local_only_session_data.proto | 3 ++ pkg/sql/vars.go | 19 +++++++ 16 files changed, 132 insertions(+), 16 deletions(-) diff --git a/docs/generated/settings/settings-for-tenants.txt b/docs/generated/settings/settings-for-tenants.txt index 6f5cab27f47d..a868c00cb4c1 100644 --- a/docs/generated/settings/settings-for-tenants.txt +++ b/docs/generated/settings/settings-for-tenants.txt @@ -171,6 +171,9 @@ This session variable default should now be configured using ALTER ROLE... SET: sql.defaults.optimizer_use_multicol_stats.enabled boolean true "default value for optimizer_use_multicol_stats session setting; enables usage of multi-column stats in the optimizer by default 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" +sql.defaults.optimizer_use_not_visible_indexes.enabled boolean false "default value for optimizer_use_not_visible_indexes session setting; disable usage of not visible indexes in the optimizer by default +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" sql.defaults.override_alter_primary_region_in_super_region.enabled boolean false "default value for override_alter_primary_region_in_super_region; allows for altering the primary region even if the primary region is a member of a super region 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" diff --git a/docs/generated/settings/settings.html b/docs/generated/settings/settings.html index c8eec0073e94..5eb4b70ec16e 100644 --- a/docs/generated/settings/settings.html +++ b/docs/generated/settings/settings.html @@ -138,6 +138,7 @@ sql.defaults.on_update_rehome_row.enabledbooleantruedefault value for on_update_rehome_row; enables ON UPDATE rehome_row() expressions to trigger on updates
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 sql.defaults.optimizer_use_histograms.enabledbooleantruedefault value for optimizer_use_histograms session setting; enables usage of histograms in the optimizer by default
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 sql.defaults.optimizer_use_multicol_stats.enabledbooleantruedefault value for optimizer_use_multicol_stats session setting; enables usage of multi-column stats in the optimizer by default
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 +sql.defaults.optimizer_use_not_visible_indexes.enabledbooleanfalsedefault value for optimizer_use_not_visible_indexes session setting; disable usage of not visible indexes in the optimizer by default
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 sql.defaults.override_alter_primary_region_in_super_region.enabledbooleanfalsedefault value for override_alter_primary_region_in_super_region; allows for altering the primary region even if the primary region is a member of a super region
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 sql.defaults.override_multi_region_zone_config.enabledbooleanfalsedefault value for override_multi_region_zone_config; allows for overriding the zone configs of a multi-region table or database
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 sql.defaults.prefer_lookup_joins_for_fks.enabledbooleanfalsedefault value for prefer_lookup_joins_for_fks session setting; causes foreign key operations to use lookup joins when possible
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 diff --git a/pkg/cli/testdata/explain-bundle/bundle/env.sql b/pkg/cli/testdata/explain-bundle/bundle/env.sql index c4a2c867b7b2..9089c9a56d72 100644 --- a/pkg/cli/testdata/explain-bundle/bundle/env.sql +++ b/pkg/cli/testdata/explain-bundle/bundle/env.sql @@ -4,6 +4,7 @@ -- enable_zigzag_join has the default value: on -- optimizer_use_histograms has the default value: on -- optimizer_use_multicol_stats has the default value: on +-- optimizer_use_not_visible_indexes has the default value: off -- locality_optimized_partitioned_index_scan has the default value: on -- distsql has the default value: auto -- vectorize has the default value: on @@ -227,6 +228,7 @@ -- sql.defaults.locality_optimized_partitioned_index_scan.enabled = true (default value for locality_optimized_partitioned_index_scan session setting; enables searching for rows in the current region before searching remote regions) -- sql.defaults.optimizer_use_histograms.enabled = true (default value for optimizer_use_histograms session setting; enables usage of histograms in the optimizer by default) -- sql.defaults.optimizer_use_multicol_stats.enabled = true (default value for optimizer_use_multicol_stats session setting; enables usage of multi-column stats in the optimizer by default) +-- sql.defaults.optimizer_use_not_visible_indexes.enabled = false (default value for optimizer_use_not_visible_indexes session setting; disable usage of not visible indexes in the optimizer by default) -- sql.defaults.override_multi_region_zone_config.enabled = false (default value for override_multi_region_zone_config; allows for overriding the zone configs of a multi-region table or database) -- sql.defaults.prefer_lookup_joins_for_fks.enabled = false (default value for prefer_lookup_joins_for_fks session setting; causes foreign key operations to use lookup joins when possible) -- sql.defaults.primary_region = (if not empty, all databases created without a PRIMARY REGION will implicitly have the given PRIMARY REGION) diff --git a/pkg/settings/registry.go b/pkg/settings/registry.go index 4544a16868a4..520460637da4 100644 --- a/pkg/settings/registry.go +++ b/pkg/settings/registry.go @@ -177,6 +177,7 @@ var sqlDefaultSettings = map[string]struct{}{ "sql.defaults.on_update_rehome_row.enabled": {}, "sql.defaults.optimizer_use_histograms.enabled": {}, "sql.defaults.optimizer_use_multicol_stats.enabled": {}, + "sql.defaults.optimizer_use_not_visible_indexes.enabled": {}, "sql.defaults.override_alter_primary_region_in_super_region.enabled": {}, "sql.defaults.override_multi_region_zone_config.enabled": {}, "sql.defaults.prefer_lookup_joins_for_fks.enabled": {}, diff --git a/pkg/sql/exec_util.go b/pkg/sql/exec_util.go index 2ca66fc41139..82c0970d2031 100644 --- a/pkg/sql/exec_util.go +++ b/pkg/sql/exec_util.go @@ -389,6 +389,21 @@ var optUseMultiColStatsClusterMode = settings.RegisterBoolSetting( true, ).WithPublic() +// optUseNotVisibleIndexesClusterMode controls the cluster default for whether +// not visible indexes can still be chosen by the optimizer for query plans. If +// enabled, the optimizer will treat not visible indexes as they are visible. +// Note that not visible indexes remain not visible, but the optimizer will +// disable not visible index feature. If disabled, optimizer will ignore not +// visible indexes unless it is explicitly selected with force index or for +// constraint check. +var optUseNotVisibleIndexesClusterMode = settings.RegisterBoolSetting( + settings.TenantWritable, + "sql.defaults.optimizer_use_not_visible_indexes.enabled", + "default value for optimizer_use_not_visible_indexes session setting; "+ + "disable usage of not visible indexes in the optimizer by default", + false, +).WithPublic() + // localityOptimizedSearchMode controls the cluster default for the use of // locality optimized search. If enabled, the optimizer will try to plan scans // and lookup joins in which local nodes (i.e., nodes in the gateway region) are @@ -3037,6 +3052,10 @@ func (m *sessionDataMutator) SetOptimizerUseMultiColStats(val bool) { m.data.OptimizerUseMultiColStats = val } +func (m *sessionDataMutator) SetOptimizerUseNotVisibleIndexes(val bool) { + m.data.OptimizerUseNotVisibleIndexes = val +} + func (m *sessionDataMutator) SetLocalityOptimizedSearch(val bool) { m.data.LocalityOptimizedSearch = val } diff --git a/pkg/sql/explain_bundle.go b/pkg/sql/explain_bundle.go index d0141f5a27ad..61875fc6720b 100644 --- a/pkg/sql/explain_bundle.go +++ b/pkg/sql/explain_bundle.go @@ -530,6 +530,7 @@ func (c *stmtEnvCollector) PrintSessionSettings(w io.Writer) error { {sessionSetting: "enable_zigzag_join", clusterSetting: zigzagJoinClusterMode, convFunc: boolToOnOff}, {sessionSetting: "optimizer_use_histograms", clusterSetting: optUseHistogramsClusterMode, convFunc: boolToOnOff}, {sessionSetting: "optimizer_use_multicol_stats", clusterSetting: optUseMultiColStatsClusterMode, convFunc: boolToOnOff}, + {sessionSetting: "optimizer_use_not_visible_indexes", clusterSetting: optUseNotVisibleIndexesClusterMode, convFunc: boolToOnOff}, {sessionSetting: "locality_optimized_partitioned_index_scan", clusterSetting: localityOptimizedSearchMode, convFunc: boolToOnOff}, {sessionSetting: "propagate_input_ordering", clusterSetting: propagateInputOrdering, convFunc: boolToOnOff}, {sessionSetting: "prefer_lookup_joins_for_fks", clusterSetting: preferLookupJoinsForFKs, convFunc: boolToOnOff}, diff --git a/pkg/sql/logictest/testdata/logic_test/information_schema b/pkg/sql/logictest/testdata/logic_test/information_schema index d80b148f9d89..9f9d5e9aff4f 100644 --- a/pkg/sql/logictest/testdata/logic_test/information_schema +++ b/pkg/sql/logictest/testdata/logic_test/information_schema @@ -4743,6 +4743,7 @@ opt_split_scan_limit 2048 optimizer on optimizer_use_histograms on optimizer_use_multicol_stats on +optimizer_use_not_visible_indexes off override_multi_region_zone_config off parallelize_multi_key_lookup_joins_enabled off password_encryption scram-sha-256 @@ -4784,7 +4785,7 @@ transaction_rows_read_log 0 transaction_rows_written_err 0 transaction_rows_written_log 0 transaction_status NoTxn -troubleshooting_mode off +troubleshooting_mode off unconstrained_non_covering_index_scan_enabled off xmloption content diff --git a/pkg/sql/logictest/testdata/logic_test/pg_catalog b/pkg/sql/logictest/testdata/logic_test/pg_catalog index b00c228c7eb2..5aa73fd783fb 100644 --- a/pkg/sql/logictest/testdata/logic_test/pg_catalog +++ b/pkg/sql/logictest/testdata/logic_test/pg_catalog @@ -4224,6 +4224,7 @@ on_update_rehome_row_enabled on NULL opt_split_scan_limit 2048 NULL NULL NULL string optimizer_use_histograms on NULL NULL NULL string optimizer_use_multicol_stats on NULL NULL NULL string +optimizer_use_not_visible_indexes off NULL NULL NULL string override_multi_region_zone_config off NULL NULL NULL string parallelize_multi_key_lookup_joins_enabled off NULL NULL NULL string password_encryption scram-sha-256 NULL NULL NULL string @@ -4349,6 +4350,7 @@ on_update_rehome_row_enabled on NULL opt_split_scan_limit 2048 NULL user NULL 2048 2048 optimizer_use_histograms on NULL user NULL on on optimizer_use_multicol_stats on NULL user NULL on on +optimizer_use_not_visible_indexes off NULL user NULL off off override_multi_region_zone_config off NULL user NULL off off parallelize_multi_key_lookup_joins_enabled off NULL user NULL false false password_encryption scram-sha-256 NULL user NULL scram-sha-256 scram-sha-256 @@ -4471,6 +4473,7 @@ opt_split_scan_limit NULL NULL NULL optimizer NULL NULL NULL NULL NULL optimizer_use_histograms NULL NULL NULL NULL NULL optimizer_use_multicol_stats NULL NULL NULL NULL NULL +optimizer_use_not_visible_indexes NULL NULL NULL NULL NULL override_multi_region_zone_config NULL NULL NULL NULL NULL parallelize_multi_key_lookup_joins_enabled NULL NULL NULL NULL NULL password_encryption NULL NULL NULL NULL NULL diff --git a/pkg/sql/logictest/testdata/logic_test/show_source b/pkg/sql/logictest/testdata/logic_test/show_source index 0fdb1eb5be67..236965287e45 100644 --- a/pkg/sql/logictest/testdata/logic_test/show_source +++ b/pkg/sql/logictest/testdata/logic_test/show_source @@ -97,6 +97,7 @@ on_update_rehome_row_enabled on opt_split_scan_limit 2048 optimizer_use_histograms on optimizer_use_multicol_stats on +optimizer_use_not_visible_indexes off override_multi_region_zone_config off parallelize_multi_key_lookup_joins_enabled off password_encryption scram-sha-256 @@ -135,7 +136,7 @@ transaction_rows_read_log 0 transaction_rows_written_err 0 transaction_rows_written_log 0 transaction_status NoTxn -troubleshooting_mode off +troubleshooting_mode off unconstrained_non_covering_index_scan_enabled off use_declarative_schema_changer on vectorize on diff --git a/pkg/sql/opt/exec/execbuilder/testdata/explain_env b/pkg/sql/opt/exec/execbuilder/testdata/explain_env index 5b27fdf88b15..fce7968fd32c 100644 --- a/pkg/sql/opt/exec/execbuilder/testdata/explain_env +++ b/pkg/sql/opt/exec/execbuilder/testdata/explain_env @@ -37,7 +37,7 @@ CREATE TABLE y ( query T EXPLAIN (OPT, ENV) SELECT * FROM x WHERE b = 3 ---- -https://cockroachdb.github.io/text/decode.html#eJy0lNGO4jYUhq_HT3GUm2UqUhK4GQWt1CybqmnZMIJ0u6vRyHISJ7gYO2s7kKGqNA_BE86TVA7MDKpEUbUaLpB8-L_j__ycxHXhM1WaSRHAROYrJUm-_PgBaEvzrGG8oAoM1QY2BxVCrguKSlVQhf-UTGjM2ZoZWBINZkmhoCVpuIEN4Q0N4MbqqSAZp3jHqh2pOuqcXAqrl7Vha7ajCjea4iXTRlaKrPX_odYNNyyXHGtDzAWSy5xwZh7wc4sC10QZZpgUtMBMFLTFOicXbNdK1qQihmIm6sbgLiQmqrNUWR4wWlKFuZSrpj5mWkqFy9V52weyYJpwLre4bDjHpgvZ2rzEcaIqeoCsHCu5PYv4nudZJpfaHJrjLTNLfJThLmK2o5esHuVG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Scfoy_Q4gyzooVe1sXR9RihcJpG839njpNfo0kKizRM40UaTxbw7g4BAPzVve3jkE3V9dwJwOu_hHPJm7XQTgB3z8ED3nk-35_iFSWGFpgYJwBn6Pk3rue7ng-eH3he4HnOCdi2nYncDrwRluB7p7m7n7xbBvNQW2POKVnYVXsintKU3L4IDkf-cNR9-7v_f0vO3qTkzuHbVY3u340Rir7cTsM4gd7sNu1DlHy-hkU0tUvxA_w8n32CFv74JZpHkMF7GI2R67ou6m6n9qfjmiF43O8f998f998hl0IbRZgwAQyGAz-Au8EIXBiM7tE_AQAA__-RT-qI statement error ENV only supported with \(OPT\) option EXPLAIN (ENV) SELECT * FROM x WHERE b = 3 @@ -49,7 +49,7 @@ EXPLAIN (ENV) SELECT * FROM x WHERE b = 3 query T EXPLAIN (OPT, ENV) SELECT * FROM x, y WHERE b = 3 ---- -https://cockroachdb.github.io/text/decode.html#eJy0ld9u4kYUxq8zT3HEzUKFGxNuIkcrlWUnrVvWRMbd7iqKRoM9hmmGGe_8cSBVpVWfgcs-XZ6kGpsktBs2qlbhAsnHv-_MOR-fcRDAe6YNVzKCscqvtaL58u0bYGuWzx0XBdNgmbFQtxRCQQCaKV0wTX5XXBoi-IpbWFIDdsmgYCV1wkJNhWMRnHqeSToXjNzyxS1dNKpDuJKeV5XlK37LNHGGkSU3Vi00XZn_o1o5YXmuBDGW2meUQuVUcLsh9y0KUlFtueVKsoJwWbA1MTl9ZuxKq4ouqGWEy8pZ0pjE5eKgqixbGSuZJkKpa1ftPC2VJuX14bFbZcENFULdkNIJQWxjsh_zOZ2gesFakceJVjcHJYMwDL0mV8a2zckNt0uyw0hjMb9lz426w62m0tDcO0s-uZ3rJTFM1zw_2ESzhRNUoxnO_NLWfBLw2rc-A3hsfk9TZ5U_s2a5Vfprs0mExikeZRiy0ZsJhsrNBc-_X0MXHVGIk-wUkmkGya-TSR8dzXeV9mo8TWZZOoqTDNakumYbuEjjd6P0I_yCP0KXwmg27vXRUZy8xR9gTeaEF2voz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n_Ewg0k2yOJJFg8n8OoaAQD80Xz7T4vWs2bnrQjC7i6cK-EW0rQiuH4KbvjW0_PNPq8Ztawg1LYiaJ2FvfMg7AVhD8JeFIZRGLb2YL92LnN_4E56QS_cr91c8sYMdlX5xlr7Yumt9ijcl2l1t0t41u-d9Zt3f3b_78jTFxm56fDlpkY3ry6ed-TKO9J94cj6kCNXzzjSPTryX1xNSk9ejlMc_5hsyLoDKb7EKU6GePJkzTbd2dnrGjvXX7Xz6lk7N1PiD1ejQZxAe3yVdQEn7zswwSPPfgeX6fgdLLuwgt9-wimGKbyG_gUKgiBAXEqmg-Y_qJ1rZUwHwcP674f154f1Z2h-pFdfRJY_bO-ff_OX3_XDer0FciWN1ZRLG8Hp2WkvguvTPgRw2r9Be1jJhWXaQNtqxzronwAAAP__IEZN0g== # # Same table twice should only show up once. @@ -58,7 +58,7 @@ https://cockroachdb.github.io/text/decode.html#eJy0ld9u4kYUxq8zT3HEzUKFGxNuIkcrl query T EXPLAIN (OPT, ENV) SELECT * FROM x one, x two ---- -https://cockroachdb.github.io/text/decode.html#eJy0lMGO2zYQhs_LpxjoEruwCnlzWXiRg-KogFpHXlhqkGCxIGhpJLOmSYWkbK2LAnkIH_t0-yQFJW_WKOAaRbA-GOLM_w1nflH0ffiE2nAlJzBV-Vorlq8-vAdsMV82XBSowaKxsO1VhPg-aFS6QE3_UFwaKviGW1gxA3aFUGDJGmFhy0SDE7hxepRsKZDuebVnVUedkyvp9Kq2fMP3qGljkK64sarSbGP-D7VphOW5EtRYZi-QQuVMcPtIn0sUtGbacsuVxIJyWWBLTc4utF1rVbOKWaRc1o2lnUlcVmepsuwxLFFTodS6qY-elkrTcn2-7Z4suGFCqB0tGyGo7Ux2bV7iBNMV9pCTU612Z5FxEASOyZWxfXG643ZFjzLaWcz3eKnVo9xqJg3LnbP0a3N0vaQG9ZbnZ4torBrBNEmjzA1tzVcB71zpW4CX4s9q1ljl9txibpX-r94kIdNFFGYRZOH7WQR1sxQ8_7mFAb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O6egwe893y-P8VrZBYLyqw3Au86GN74wdAPhhAMR0EwCgLvBOzGzmXuFt5IRxgGp7W7P3l3GexD7Yx5p2TprtoT8ZSm1fZF8Pr98Pp9l_tr8H9bXrxJy53Dt-ua3L8bExJ9vZ2GcQK92W02gCj50oc0mrpL8RP8Mp99hhbCFJTEweGX3aox8X3fJ1xK1H73PvdyrYzpE3jc__24__G4_wHdA9bCHTMflMT7Mym7VV1qf0yVXFjUBnpWN9gn_wQAAP__VMcDCw== # # Set a relevant session variable to a non-default value and ensure it shows up @@ -71,7 +71,7 @@ SET reorder_joins_limit = 63 query T EXPLAIN (OPT, ENV) SELECT * FROM y WHERE u = 3 ---- -https://cockroachdb.github.io/text/decode.html#eJyUkt9O2zAYxa_xU3x3tBMZoEoTasVFCGbLVlKUeAyEkGUSJ_XqxsF_QtMrHqJPyJNMScoNWlftMtHvd3x09Hke3HJthCrHEKh0oRVL55cXwFc8fXJCZlyD5cZC3VMIJZiA5kpnXNPfSpSGSrEUFs7hy2gC4HmQ8Zw5aaFm0vExnCHPA16yJ8npWhRrVnQezJkBO-cfcVW2vKqsWIo119QZTufCWFVotjT_Yy2dtCJVkhrL7B5TqpRJYRv6HpHRimkrrFAlz6goM76iJmV7aldaVaxgllNRVs7SbiZRFjutPO81nnNNpVILV21XzZWm-WJ37d7MhGFSqheaOymp7UZua-7zJNMF76UWp1q97FROT05OWidVxvbh9EXYOd1itJtYrPm-qlvcalYalrbL0me3XT2nhutapDtDNC-cZLo7v0wYa54lnLfRf7055qxq36x5apX-V7cSoSDGPsFA_Isphso9SZF-bmCADhyEETmDaEYg-jmdHqGDevun_wpmUUJiP4wINLRa8AZu4vDaj-_hB76HgQM_CYYfuZrmLXk1i3H4NerJeggxvsIxjgKcvFdYDVgrh9Elvus8ka1gUHehaDhByJ8SHH-sHUbfcUAgIT4JExIGCRw-PB5OEMJ3N1M_jGAwuyFHgKPbISR42rKf4CqeXUMDv77hGIODcxhNkOd5HuouvkHwttm8bV7fNq-QqtJYzURpx3B8OoaH4xF4cDx6RH8CAAD__ygWcbs= +https://cockroachdb.github.io/text/decode.html#eJyUks1O4zwUhtf4Ks6O9hP5AFUaoVYsQjAzmSkpSjwMCCHLJE7qqRsH_4S2Ky6iV8iVjJyWDZpOxTLR87x-7XOCAG65NkLVQ4hUPtOK5dPLC-ALnj85IQuuwXJjod1QCGWYgOZKF1zT30rUhkoxFxbO4ctgBBAEUPCSOWmhZdLxIZyhIABesyfJ6UpUK1Z1HkyZATvlH3FVe141VszFimvqDKdTYayqNJubz1hzJ63IlaTGMvsps1aWtsIIX1nUBV_w3XpZel-qnElhl_Q9qKAN01ZYoWpebEKoydmeazdaNaxi1h_bOEu7ZxZ1tef0RvOSayqVmrlmO5VSaVrO9vUuhGFSqhdaOimp7Ybka-69L9MV30gep1q97FROT05OvJMrYzfh9EXYKd1itBuRWPF9Vbe41aw2LPcvS5_d9tVLarhuRb4zRPPKSaa79S2EseZZwrmP_uvOMmeVP7PluVX6X91qhKIUhwQDCS_GGBr3JEX-_xJ66MBBnJAzSCYEkp_j8RE6aLd_Nl_RJMlIGsYJgSVtZnwJN2l8Hab38APfQ89BmEX9j1xLS09eTVIcf002ZNuHFF_hFCcRzt4rLHrMy3Fyie86TxQL6LVdKOqPEArHBKcfa8fJdxwRyEhI4ozEUQaHD4-HI4Tw3c04jBPoTW7IEeDktg8ZHnv2P7hKJ9ewhF_fcIrBwTkMRigIggB1G79E8LZev61f39avkKvaWM1EbYdwfDqEh-MBBHA8eER_AgAA___jy4mu # Make sure it shows up correctly even if it matches the cluster setting. statement ok @@ -81,7 +81,7 @@ SET CLUSTER SETTING sql.defaults.reorder_joins_limit = 63 query T EXPLAIN (OPT, ENV) SELECT * FROM y WHERE u = 3 ---- -https://cockroachdb.github.io/text/decode.html#eJyUkt9O2zAYxa_xU3x3tBMZoEoTasVFCGbLVlKUeAyEkGUSJ_XqxsF_QtMrHqJPyJNMScoNWlftMtHvd3x09Hke3HJthCrHEKh0oRVL55cXwFc8fXJCZlyD5cZC3VMIJZiA5kpnXNPfSpSGSrEUFs7hy2gC4HmQ8Zw5aaFm0vExnCHPA16yJ8npWhRrVnQezJkBO-cfcVW2vKqsWIo119QZTufCWFVotjT_Yy2dtCJVkhrL7B5TqpRJYRv6HpHRimkrrFAlz6goM76iJmV7aldaVaxgllNRVs7SbiZRFjutPO81nnNNpVILV21XzZWm-WJ37d7MhGFSqheaOymp7UZua-7zJNMF76UWp1q97FROT05OWidVxvbh9EXYOd1itJtYrPm-qlvcalYalrbL0me3XT2nhutapDtDNC-cZLo7v0wYa54lnLfRf7055qxq36x5apX-V7cSoSDGPsFA_Isphso9SZF-bmCADhyEETmDaEYg-jmdHqGDevun_wpmUUJiP4wINLRa8AZu4vDaj-_hB76HgQM_CYYfuZrmLXk1i3H4NerJeggxvsIxjgKcvFdYDVgrh9Elvus8ka1gUHehaDhByJ8SHH-sHUbfcUAgIT4JExIGCRw-PB5OEMJ3N1M_jGAwuyFHgKPbISR42rKf4CqeXUMDv77hGIODcxhNkOd5HuouvkHwttm8bV7fNq-QqtJYzURpx3B8OoaH4xF4cDx6RH8CAAD__ygWcbs= +https://cockroachdb.github.io/text/decode.html#eJyUks1O4zwUhtf4Ks6O9hP5AFUaoVYsQjAzmSkpSjwMCCHLJE7qqRsH_4S2Ky6iV8iVjJyWDZpOxTLR87x-7XOCAG65NkLVQ4hUPtOK5dPLC-ALnj85IQuuwXJjod1QCGWYgOZKF1zT30rUhkoxFxbO4ctgBBAEUPCSOWmhZdLxIZyhIABesyfJ6UpUK1Z1HkyZATvlH3FVe141VszFimvqDKdTYayqNJubz1hzJ63IlaTGMvsps1aWtsIIX1nUBV_w3XpZel-qnElhl_Q9qKAN01ZYoWpebEKoydmeazdaNaxi1h_bOEu7ZxZ1tef0RvOSayqVmrlmO5VSaVrO9vUuhGFSqhdaOimp7Ybka-69L9MV30gep1q97FROT05OvJMrYzfh9EXYKd1itBuRWPF9Vbe41aw2LPcvS5_d9tVLarhuRb4zRPPKSaa79S2EseZZwrmP_uvOMmeVP7PluVX6X91qhKIUhwQDCS_GGBr3JEX-_xJ66MBBnJAzSCYEkp_j8RE6aLd_Nl_RJMlIGsYJgSVtZnwJN2l8Hab38APfQ89BmEX9j1xLS09eTVIcf002ZNuHFF_hFCcRzt4rLHrMy3Fyie86TxQL6LVdKOqPEArHBKcfa8fJdxwRyEhI4ozEUQaHD4-HI4Tw3c04jBPoTW7IEeDktg8ZHnv2P7hKJ9ewhF_fcIrBwTkMRigIggB1G79E8LZev61f39avkKvaWM1EbYdwfDqEh-MBBHA8eER_AgAA___jy4mu statement ok SET enable_zigzag_join = false @@ -89,7 +89,7 @@ SET enable_zigzag_join = false query T EXPLAIN (OPT, ENV) SELECT * FROM y WHERE u = 3 ---- -https://cockroachdb.github.io/text/decode.html#eJyMks9O4zoYxdf4Kb4d7RW5gCpdoVYsQjD35k5JUeJhQAhZJnFST107-E9ou-Ih-oQ8yShJ2aApzDLR73d8dPQFAdxyY4VWY4h0vjCa5fPLC-Arnj95IQtuwHHroOkphDJMwHBtCm7oTy2UpVIshYNz-Gc0AQgCKHjJvHTQMOn5GM46hSv2JDndiGrDqk6Ec9Bl-VtFKxQEoGsnlmLDDfWW07mwTleGLS3MmQU3539iLb10IteSWsfcF6bUOZPCrel7REFrZpxwQiteUKEKvqI2Z-rzmNromlXMcSpU7R3tphKq2muVZa_xkhsqtV74erdsqQ0tF_tr92YhLJNSv9DSS0ldt3Nb8ytPMlPxXmpxavTLXuX05OSkdXJtXR9OX4Sb0x1Gu4nFhn9VdYc7w5Rlebssffa71UtquWlEvjfE8MpLZrp7KoR19ll-ckTMO92-2fDcafNZN4VQlOKQYCDhxRRD7Z-kyP9ewwAdeIgTcgbJjEDyfTo9QgfN7k__Fc2SjKRhnBBY03rB13CTxtdheg_f8D0MPIRZNPzINbRsyatZiuN_k55shpDiK5ziJMLZe4XVgLVynFziu84TxQoGTReKhhOEwinB6cfacfI_jghkJCRxRuIog8OHx8MJQvjuZhrGCQxmN-QIcHI7hAxPW_YvuEpn17CGH__hFIOHcxhNUBAEAeoufo3gbbt9276-bV8h18o6w4RyYzg-HcPD8QgCOB49ol8BAAD__1J7ch0= +https://cockroachdb.github.io/text/decode.html#eJyUkt9O2zAUh6_xU5w72okMUKUJteIiBLNlKylKPAZCyDKJk3p17eA_oe0VD9En5EmmpOUGDbpdJvp953w-5wQBXHNjhVZDiHQ-M5rl0_Mz4AueP3ghC27Aceug2aQQyjABw7UpuKG_tVCWSjEXDk7hy2AEEARQ8JJ56aBh0vMhnHQIV-xBcroS1YpVHQinoMvyr4hWKAhA107MxYob6i2nU2GdrgybW5gyC27K_4Wae-lEriW1jrn_IpV2tBFWtNZCFXzB38fLsuWlzpkUbklfCxW0ZsYJJ7TixaYItTlTH2vURtesYq5tW3tHu1ELVe3oXhteckOl1jNfbzdTakPL2S7vQlgmpX6ipZeSum5PrebO9zJT8Q3UxqnRT-8ix0dHRy2Ta-s2xemTcFO6jdFuRWLFd6lu484wZVneTpY--u3US2q5aUT-bhHDKy-Z6e6xENbZR_nBETLvdNuz4bnT5iM3hVCU4pBgIOHZGEPtH6TIPy-hh_Y8xAk5gWRCIPk5Hh-gvWb7Z_MVTZKMpGGcEFjSesaXcJXGl2F6Cz_wLfQ8hFnUf5traNkmLyYpjr8mm2TThxRf4BQnEc5eFRY91sJxco5vOk4UC-g1XVHUHyEUjglO32rHyXccEchISOKMxFEG-3f3-yOE8M3VOIwT6E2uyAHg5LoPGR632U9wkU4uYQm_vuEUg4dTGIxQEAQB6i5-ieBlvX5ZP7-snyHXyjrDhHJDODwewt3hAAI4HNyjPwEAAP__Jr-KEA== statement ok SET optimizer_use_histograms = false @@ -97,7 +97,7 @@ SET optimizer_use_histograms = false query T EXPLAIN (OPT, ENV) SELECT * FROM y WHERE u = 3 ---- -https://cockroachdb.github.io/text/decode.html#eJyEks1O4zwYhdf4Kt4d7SfyAao0Qq1YhGJmMlNSlHgYEEKWSZzUU9cO_gltV1xEr5ArGSUpG0TLMtHzHB8dv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J6cnLRMrq3bFKcvwk3pNka7FYkV36e6jTvDlGV5O1n67LdTL6nlphH5p0UMr7xkpruvQlhnn-WOc2Le6bZnw3OnzS43hVCU4pBgIOHFGEPtn6TI_19CDx14iBNyBsmEQPJzPD5CB832z-YrmiQZScM4IbCk9Ywv4SaNr8P0Hn7ge-h5CLOo_zHX0LJNXk1SHH9NNsmmDym-wilOIpy9Kyx6rIXj5BLfdZwoFtBruqKoP0IoHBOcftSOk-84IpCRkMQZiaMMDh8eD0cI4bubcRgn0JvckCPAyW0fMjxus__BVTq5hiX8-oZTDB7OYTBCQRAEqLv4JYK39fpt_fq2foVcK-sME8oN4fh0CA_HAwjgePCI_gQAAP__psKKcg== statement ok SET optimizer_use_multicol_stats = false @@ -105,7 +105,7 @@ SET optimizer_use_multicol_stats = false query T EXPLAIN (OPT, ENV) SELECT * FROM y WHERE u = 3 ---- -https://cockroachdb.github.io/text/decode.html#eJyUkt9O2zAYxa_xU3x3tBMZoEoTasVFCGbLVlKUeAyEkGUSJ_Xq2sF_QtsrHqJPyJNMScsNAqpdJvr9To7OlyCAa26s0GoIkc5nRrN8en4GfMHzBy9kwQ04bh00GwqhDBMwXJuCG_pXC2WpFHPh4BS-DUYAQQAFL5mXDhomPR_CSadwxR4kpytRrVjViXAKuizfVbTqHF07MRcrbqi3nE6FdboybG7_15x76USuJbWOuR12EIDUOZPCLelrSkFrZpxwQiteUKEKvqA2ZwqmzIKb8vdjaqNrVjHHqVC1d7SbTKjqQ6ssNxovuaFS65mvtwuX2tByZneYhbBMSv1ESy8ldd3ebc1dnmSm4hupxanRTx8qx0dHR62Ta-s24fRJuCndYrRbWaz4rqpb3BmmLMvbZemj365eUstNI_IPQwyvvGSmu3QhrLOP8pOjMu90-82G506bz7ophKIUhwQDCc_GGGr_IEX-dQk9tOchTsgJJBMCye_x-ADtNds3m6dokmQkDeOEwJLWM76EqzS-DNNb-IVvoechzKL-W66hZUteTFIcf082ZNOHFF_gFCcRzl4rLHqslePkHN90nigW0Gu6UNQfIRSOCU7f1o6TnzgikJGQxBmJowz27-73Rwjhm6txGCfQm1yRA8DJdR8yPG7ZL3CRTi5hCX9-4BSDh1MYjFAQBAHq_vglgpf1-mX9_LJ-hlwr6wwTyg3h8HgId4cDCOBwcI_-BQAA__9j8nLh +https://cockroachdb.github.io/text/decode.html#eJyUkt9O2zAUxq_xU5w72okMUKUJteIiBLNlKylKPAZCyDKJk3p17eA_oe0VD9En5EmmpOWGDapdJvp-3_l8zhcEcM2NFVoNIdL5zGiWT8_PgC94_uCFLLgBx62DZqNCKMMEDNem4Ib-1kJZKsVcODiFL4MRQBBAwUvmpYOGSc-HcNIhXLEHyelKVCtWdSCcgi7LfyJadYyunZiLFTfUW06nwjpdGTa3_0vOvXQi15Jax9wOOgjewEo72ggr2vRCFXzBLUyZBTflf-Fl2fJS50wKt6SvRgWtmXHCCa14sTGhNmfqXZ8uRm10zSrm2rG1d7RbuVDVjum14SU3VGo98_X2QqU2tJztyl0Iy6TUT7T0UlLX3auNufO9zFR8A7VyavTTu8jx0dFRy-Tauo05fRJuSrcy2l1JrPiuqFu5M0xZlrebpY9-u_WSWm4akb9rYnjlJTNdUwphnX2UH5SCeafbmQ3PnTYfZVMIRSkOCQYSno0x1P5BivzzEnpoz0OckBNIJgSSn-PxAdprtn82X9EkyUgaxgmBJa1nfAlXaXwZprfwA99Cz0OYRf23uoaWrfJikuL4a7JRNn1I8QVOcRLh7DXCosdaOE7O8U3HiWIBvaYzRf0RQuGY4PRt7Dj5jiMCGQlJnJE4ymD_7n5_hBC-uRqHcQK9yRU5AJxc9yHD41b7CS7SySUs4dc3nGLwcAqDEQqCIEBd45cIXtbrl_Xzy_oZcq2sM0woN4TD4yHcHQ4ggMPBPfoTAAD__2k2itQ= statement ok RESET reorder_joins_limit @@ -129,7 +129,7 @@ CREATE SEQUENCE seq query T EXPLAIN (OPT, ENV) SELECT * FROM seq ---- -https://cockroachdb.github.io/text/decode.html#eJyUkk2P2jwUhff5FXf5vlVT8dEZ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AW0cWFIfwq4gcmomA_GzwK6MBm8HJ9frq56vf5Vp3dze_2537--7fRhVAynYiKKErowKwfTErr3WSZensaDUQHvHp_KjyCK-XuYibEYlvABvk8fJxBwc5_leZ5nATcRrcY8oEHN6Sf7HQAA___SiVcf # # Test views. @@ -141,7 +141,7 @@ CREATE VIEW v AS SELECT a, b, u, v FROM x, y WHERE b = 3 query T EXPLAIN (OPT, ENV) SELECT * FROM v ---- -https://cockroachdb.github.io/text/decode.html#eJy0Vd1uIjcYvY6f4hM3C9XMZghSFYEilWWddlp2iIZpdldRZJkZD7gxNuufCaSqtOozcNmny5NUHiBhd8NGVRUukPzNOZ_Pd3wshyFcMm24kl0YqPxGK5rP3r4BtmT5xHFRMA2WGQvVBoXQGGegmdIF0-QPxaUhgs-5hTP4sdMDCEMoWEmdsFBR4VgXTlEYApN0Ihi549M7Oq15MKMG7Ix9DVfS49XC8jm_Y5o4w8iMG6umms7Nf2HNnbA8V4IYS-0zTKFyKrhdkV2LgiyottxyJVlBuCzYkpicPiN7odWCTqllhMuFs6S2icvpQVZZbmisZJoIpW7cYutqqTQpbw7L3jALbqgQ6paUTghia5O9zOd4guop25A8nGh1e5DSjqLIc3Jl7KY5ueV2RrYwUlvM79hzUrdwq6k0NPfOkk9u63pJDNMVzw820WzqBNV1_ApurPkk4My3fjJz1Fnl96xYbpX-njaJ0CDF_QxD1n8zxLBwE8Hz10tooiMKcZKdQjLKIPl9OAzQ0WRb2awGo2Scpf04yWBJFjdsBRdp_K6ffoTf8EdoUuiPB60AHcXJW_wBlmRCeLGE5qSuo1YPof4ww-nXO8fJr3iQwTjrZ_E4iwdjeHWFAAD-rP_9r0Grae15owtR8FjOlXBzaRpduHoobvCNh_X1Pl4zallBqG10oXEStU_DqB1GbYja3SjqRlFjD-xt5zL3B-6kJ7Sj_b3rS1qHwa4WXlhjnyx91HbEfZpWt48NTzrtk0797a_g_448eZGRa4UvNzW6ftV7OpErn0j3TSKrQ4lcPZFIt0vkF7iKlB55Pkp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mt0_WLwtCNXzpH2C0fWzzly9YQj7c6Rn-BqUjjk-STG4a_RBll3IMbnOMbRCE8frNmmj3Z2vMbO9VftvHrSzvtdXob47Q5dN9fOXTQPHVnXHurAcApTPHYa1IPUA-tBDefx5E3zsr3cFed9clzB299wjCGFM-gNEMLvLsbDMIL25CLxAEeXnZ3oTxuteoB83_cRL0um_OaFa2dKat1BcL_-73798X79EZonYPVFZPnL9na7L_-6Td6v11tAJkttFOWl6cPxyXG3D1fHPfDhuHeN9mAFF4YpDW2jLOug_wMAAP__ui9nYg== # # Test tables in user-defined schemas. @@ -154,7 +154,7 @@ CREATE TABLE s.t (a int primary key) query T EXPLAIN (OPT, ENV) SELECT * FROM s.t; ---- -https://cockroachdb.github.io/text/decode.html#eJyUktFq20wQha-zTzF3sX-iH5dCCTG5UFQV1CqykbahoZRhI43krddaZXdkJ376ItmFUuqa3n_fmcNhggAeyHlt2xuIbLl2VpWr93dAL1Q-9dpU5IDJM2wPlBBFLMGRdRU5_G5169HojWa4hXdv5wBBABXVqjcMW2V6uoFrEQRArXoyhHvd7FUzerBSHnhFv-O2HXjbsd7oPTnsPeFKe7aNUxv_L9amN6xLa9Cz4jOmsaUyml_xZ0SFnXKsWduWKtRtRS_oS3WmdudspxrFhLrtesZxJt02J626PmhUk0Nj7brvjqvW1mG9Pl37YFbaK2PsDuveGORx5KHmOc8o19BBGnB0dndSeTObzQantJ4P4bjTvMIjhuPEek_nqh5xdqr1qhyWxef-uHqNntxWlydDHDW9UW58v0p79s8GbofoP_6c6tkON7dUsnV_69YKEeVxKGOQ4V0ag_-fYSIuFCSZvIZsISH7nKZX4iJaZIXMwySTwNit6RWWeXIf5o_wKX6EiYKwiKZiOhciTGWc_xKXZB_jSEIhQ5kUMokKuPz67XIuRPxlmYZJBpPFUl5BnD1MoYjTgf0PPuSL-8GeiyAIAjG-HosfAQAA___OrkHU +https://cockroachdb.github.io/text/decode.html#eJyUktFr2zAQxp-rv-Le2ox6ZAxGaeiD63ngzXWCrZWVMYRqnx0tiuVKp6TNXz_kZDDGstD37_fdd3dfFME9WqdMfw2JqVfWyHr58RbwGetHr3SDFggdwWavYqxKOVg0tkErfhrVO6HVWhHcwIf3M4AoggZb6TXBRmqP13DFogiwl48axU51O9mNHCylA1ri33LTB70ZSK3VDq3wDsVSOTKdlWv3GmrtNanaaOFI0qvI3pDYKKdCZNU3-IzH8bYNvDa11IpexG-jRgzSkiJlemz2JsLV8sTagzWD7CSFsYMnMZ5Z9d2J6YPFFq3Qxqz8cPhKa6xoV6dyN8pJrc1WtF5rQeOTQsyT-0rb4R4KcmHN9ijybjqdBqY2jvbmYqtoKQ4yMb5I7fBU1IOcrOydrMNlxZM_XL0VDu1G1UdNLHZeSzvWt1GO3JOGm2D9z85KTybM3GBNxv4vW89YUqYxT4HHt3kK7i3BBTuTkBX8Coo5h-Jrnl-ys2ReVLyMs4IDiWGFL7Aos7u4fIAv6QNcSIirZMImM8binKflH3ZZ8TlNOFQ85lnFs6SC8-8_zmeMpd8WeZwVcDFf8EtIi_sJVGketG_gUzm_C_SMRVEUsbF6xH4FAAD___F9Wcc= # # Test default_transaction_quality_of_service settings. @@ -166,7 +166,7 @@ SET default_transaction_quality_of_service=background query T EXPLAIN (OPT, ENV) VALUES(1); ---- -https://cockroachdb.github.io/text/decode.html#eJyUkkFqG00QhfdzilpK4AGJH36CjRZOokXAOAY7Irui1VMzqqjVNa6ulhytfAidUCcJMyNvgmWR_fe9ejyqLGFBmljiNXwRv1ZxfvX1M9AL-WXmUJGCUTLYDlRRPM6fQEm0IsVfwjFh4A0bzOD__24AyhIqql0OBlsXMl3Dp6IsgaJbBsI9N3vX9B6sXAJb0d-4xI6X1njDe1LMiXDFyaRRt0n_Ym1yMPYSMJmzC2YQ7wLbb3yLqLB1amwskSrkWNELJu8u1G5VWtc4I-TYZsN-Jo7NWauuB41qUgwi69yeVq1FsV6frz2YFScXguywziGg9SN3NS95wWlDg9ThqLI7q0wnk0nneEk2hOOObYUnDPuJeU8fney-5o03dTE5302Lz_k0e42JdMueYAZL59eNSo7Vuw-l1OTgdMjkZOk5wKy78i7tsknXfkveRD-qGYti_vPh7vbbPYy-Pzxdwfx-MYbF7d2P-SOMpuOboizLsujxVMDxcDgeXo-HVxhNr8bFnwAAAP__2DQrKQ== +https://cockroachdb.github.io/text/decode.html#eJyUksFuGkEMhu_7FD6ClJVAlaoqEYe05VApSiMlRb1Zw6x3cRnGG48HUk55CJ6QJ6kGyKVKgnL_Pv__2FPXMCNNLPESvolfqji_-P4V6In8PHNoSMEoGayPVFXdTx9ASbQhxT_CMWHgFRtM4POnK4C6hoZal4PB2oVMl_Clqmug6OaBcMvd1nUHDxYugS3of1xi4aU3XvGWFHMiXHAy6dSt0kesVQ7GXgImc_YhM4rhmhOXyhwbeqK39bYtfhDvAttffBnUYO_U2FgiNcchmLw78-xepXedsxLbZ8PDmjl2Z9J7pZYUg8gy96ertKLYLs_1bji5EGSDbQ4B7XCkUvPse512dJQKjiqbN5XxaDQqjpdkx-G4YVvgCcPDiXhL70WWX_fCm7qYnC-rxcd8WnuLiXTNnmACc-eXnUqOzasfUqnLwelxJidLjwEmJeVV2mWT0n5N3kTfqxmravr77ub6xy0Mft49XMD0djaE2fXNr-k9DMbDq6qu67o64KmC_W633z3vd88wGF8Mq38BAAD__4edQxw= statement ok SET default_transaction_quality_of_service=critical @@ -174,4 +174,4 @@ SET default_transaction_quality_of_service=critical query T EXPLAIN (OPT, ENV) VALUES(1); ---- -https://cockroachdb.github.io/text/decode.html#eJyUksFq20AQhu96ijnaEIFNoZQEH9LWh0JIA0lNb8NmNZKnXu8os7N26lMewk_oJymSnEuJY3L_vn9-fqYsYUGaWOIlfBO_UnF--f0r0DP5x8yhIgWjZLAZqKK4nz-AkmhFin-EY8LAazaYwedPVwBlCRXVLgeDjQuZLuFLUZZA0T0Gwh03O9f0HixdAlvS_7jEjpfWeM07UsyJcMnJpFG3Th-x1jkYewmYzNkZM4h3ge0vvkZU2Do1NpZIFXKs6BmTd2dqtyqta5wRcmyzYT8Tx-akVdeDRjUpBpFVbo-r1qJYr07XHsyKkwtBtljnEND6kbua57zgtKFB6nBU2Z5UppPJpHO8JBvCccu2xCOG_cS8o_dOdl_zypu6mJzvpsWnfJy9xkS6YU8wA69s7F14852UmhycDomcLD0FmHU33qRdNum6b8ib6HslY1HMf9_dXP-4hdHPu4cLmN8uxrC4vvk1v4fRdHxVlGVZFj2eCjjs94f9y2H_AqPpxbj4FwAA__9iIypU +https://cockroachdb.github.io/text/decode.html#eJyUksFqG0EMhu_7FDrGkAWbQikJPqStD4WQBpKa3sRkVrtWPR5tNBo79SkP4Sf0k5TxOpeSxOT-ffr_kaauYU6aWOIFfBO_VHF-8f0r0BP5h8yhIQWjZLAeqKq6m92DkmhDin-EY8LAKzaYwudPlwB1DQ21LgeDtQuZLuBLVddA0T0Ewi13W9cdPFi4BLag_3GJhZfeeMVbUsyJcMHJpFO3Sh-xVjkYewmYzNmHzCiGa05cKnNs6Ine1tu2-EG8C2x_8WVQg71TY2OJ1AxDMHl34tm9Su86ZyW2z4aHNXPsTqT3Si0pBpFl7o9XaUWxXZ7q3XByIcgG2xwC2uFIpebJ9zrtaJAKjiqbN5XJeDwujpdkw3DcsC3wiOHhRLyl9yLLr3vhTV1MzpfV4mM-rr3FRLpmTzAFr2zsXXj1Oyp1OTgdJnKy9BhgWjJepV02Kd3X5E30vZKxqma_b6-vftzA2c_b-3OY3cxHML-6_jW7g7PJ6LKq67quDniqYL_b7XfP-90znE3OR9W_AAAA___hl0JH diff --git a/pkg/sql/opt/exec/execbuilder/testdata/not_visible_index b/pkg/sql/opt/exec/execbuilder/testdata/not_visible_index index 2a8699f7d8a9..8a38da047234 100644 --- a/pkg/sql/opt/exec/execbuilder/testdata/not_visible_index +++ b/pkg/sql/opt/exec/execbuilder/testdata/not_visible_index @@ -1322,3 +1322,55 @@ vectorized: true statement ok DROP TABLE t + +# The following tests check session variable optimizer_use_not_visible_indexes. +statement ok +CREATE TABLE t (k INT PRIMARY KEY, v INT, INDEX idx_v_visible(v) NOT VISIBLE) + +# By default, optimizer_use_not_visible_indexes is false. +query T +SHOW SESSION optimizer_use_not_visible_indexes +---- +off + +# idx_v_visible is not selected if it is invisible. +query T +EXPLAIN SELECT * FROM t WHERE v = 2 +---- +distribution: local +vectorized: true +· +• filter +│ filter: v = 2 +│ +└── • scan + missing stats + table: t@t_pkey + spans: FULL SCAN + +statement ok +SET SESSION optimizer_use_not_visible_indexes = true + +# idx_v_visible stays as a not visible index but will still be used for query plan. +query TTB +SELECT index_name, column_name, visible FROM [SHOW INDEX FROM t] ORDER BY index_name, seq_in_index +---- +idx_v_visible v false +idx_v_visible k false +t_pkey k true +t_pkey v true + +# idx_v_visible is selected now since the optimizer_use_not_visible_indexes is true now. +query T +EXPLAIN SELECT * FROM t WHERE v = 2 +---- +distribution: local +vectorized: true +· +• scan + missing stats + table: t@idx_v_visible + spans: [/2 - /2] + +statement ok +DROP TABLE t diff --git a/pkg/sql/opt/memo/memo.go b/pkg/sql/opt/memo/memo.go index 965229328296..d9dfecc6a878 100644 --- a/pkg/sql/opt/memo/memo.go +++ b/pkg/sql/opt/memo/memo.go @@ -139,6 +139,7 @@ type Memo struct { zigzagJoinEnabled bool useHistograms bool useMultiColStats bool + useNotVisibleIndex bool localityOptimizedSearch bool safeUpdates bool preferLookupJoinsForFKs bool @@ -188,6 +189,7 @@ func (m *Memo) Init(evalCtx *eval.Context) { zigzagJoinEnabled: evalCtx.SessionData().ZigzagJoinEnabled, useHistograms: evalCtx.SessionData().OptimizerUseHistograms, useMultiColStats: evalCtx.SessionData().OptimizerUseMultiColStats, + useNotVisibleIndex: evalCtx.SessionData().OptimizerUseNotVisibleIndexes, localityOptimizedSearch: evalCtx.SessionData().LocalityOptimizedSearch, safeUpdates: evalCtx.SessionData().SafeUpdates, preferLookupJoinsForFKs: evalCtx.SessionData().PreferLookupJoinsForFKs, @@ -321,6 +323,7 @@ func (m *Memo) IsStale( m.zigzagJoinEnabled != evalCtx.SessionData().ZigzagJoinEnabled || m.useHistograms != evalCtx.SessionData().OptimizerUseHistograms || m.useMultiColStats != evalCtx.SessionData().OptimizerUseMultiColStats || + m.useNotVisibleIndex != evalCtx.SessionData().OptimizerUseNotVisibleIndexes || m.localityOptimizedSearch != evalCtx.SessionData().LocalityOptimizedSearch || m.safeUpdates != evalCtx.SessionData().SafeUpdates || m.preferLookupJoinsForFKs != evalCtx.SessionData().PreferLookupJoinsForFKs || diff --git a/pkg/sql/opt/memo/memo_test.go b/pkg/sql/opt/memo/memo_test.go index 276c0596cd9c..2c4505c0b69d 100644 --- a/pkg/sql/opt/memo/memo_test.go +++ b/pkg/sql/opt/memo/memo_test.go @@ -208,6 +208,12 @@ func TestMemoIsStale(t *testing.T) { evalCtx.SessionData().OptimizerUseMultiColStats = false notStale() + // Stale optimizer not visible indexes usage enable. + evalCtx.SessionData().OptimizerUseNotVisibleIndexes = true + stale() + evalCtx.SessionData().OptimizerUseNotVisibleIndexes = false + notStale() + // Stale locality optimized search enable. evalCtx.SessionData().LocalityOptimizedSearch = true stale() diff --git a/pkg/sql/opt/xform/scan_index_iter.go b/pkg/sql/opt/xform/scan_index_iter.go index e82696aee158..c9f4bc0d1776 100644 --- a/pkg/sql/opt/xform/scan_index_iter.go +++ b/pkg/sql/opt/xform/scan_index_iter.go @@ -228,7 +228,8 @@ func (it *scanIndexIter) ForEachStartingAfter(ord int, f enumerateIndexFunc) { } else { // If we are not forcing any specific index and not visible index feature is // enabled here, ignore not visible indexes. - if index.IsNotVisible() && !it.scanPrivate.Flags.DisableNotVisibleIndex { + if index.IsNotVisible() && !it.scanPrivate.Flags.DisableNotVisibleIndex && + !it.evalCtx.SessionData().OptimizerUseNotVisibleIndexes { continue } } diff --git a/pkg/sql/sessiondatapb/local_only_session_data.proto b/pkg/sql/sessiondatapb/local_only_session_data.proto index a94e11c0b90c..e150430a5722 100644 --- a/pkg/sql/sessiondatapb/local_only_session_data.proto +++ b/pkg/sql/sessiondatapb/local_only_session_data.proto @@ -271,6 +271,9 @@ message LocalOnlySessionData { // given probability. This should only be used in test scenarios and is very // much a non-production setting. double testing_optimizer_disable_rule_probability = 73; + // OptimizerUseNotVisibleIndexes indicates whether the optimizer can still + // choose to use visible indexes for query plans. + bool optimizer_use_not_visible_indexes = 74; /////////////////////////////////////////////////////////////////////////// // WARNING: consider whether a session parameter you're adding needs to // diff --git a/pkg/sql/vars.go b/pkg/sql/vars.go index 672f6631f771..fabf6d5a418e 100644 --- a/pkg/sql/vars.go +++ b/pkg/sql/vars.go @@ -748,6 +748,25 @@ var varGen = map[string]sessionVar{ }, }, + // CockroachDB extension. + `optimizer_use_not_visible_indexes`: { + GetStringVal: makePostgresBoolGetStringValFn(`optimizer_use_not_visible_indexes`), + Set: func(_ context.Context, m sessionDataMutator, s string) error { + b, err := paramparse.ParseBoolVar("optimizer_use_not_visible_indexes", s) + if err != nil { + return err + } + m.SetOptimizerUseNotVisibleIndexes(b) + return nil + }, + Get: func(evalCtx *extendedEvalContext, _ *kv.Txn) (string, error) { + return formatBoolAsPostgresSetting(evalCtx.SessionData().OptimizerUseNotVisibleIndexes), nil + }, + GlobalDefault: func(sv *settings.Values) string { + return formatBoolAsPostgresSetting(optUseNotVisibleIndexesClusterMode.Get(sv)) + }, + }, + // CockroachDB extension. `locality_optimized_partitioned_index_scan`: { GetStringVal: makePostgresBoolGetStringValFn(`locality_optimized_partitioned_index_scan`),