From 9a0c512a86c2ded7ca7ae9f2bbb3c57954327a24 Mon Sep 17 00:00:00 2001 From: Mark Sirek Date: Thu, 11 Aug 2022 10:52:48 -0700 Subject: [PATCH] opttester: This commit removes session setting flags from OptTester.Flags Release note: none --- pkg/sql/opt/memo/testdata/stats_quality/tpcc | 50 +++++------ .../opt/memo/testdata/stats_quality/tpch/q01 | 2 +- .../opt/memo/testdata/stats_quality/tpch/q02 | 2 +- .../opt/memo/testdata/stats_quality/tpch/q03 | 2 +- .../opt/memo/testdata/stats_quality/tpch/q04 | 2 +- .../opt/memo/testdata/stats_quality/tpch/q05 | 2 +- .../opt/memo/testdata/stats_quality/tpch/q06 | 2 +- .../opt/memo/testdata/stats_quality/tpch/q07 | 2 +- .../opt/memo/testdata/stats_quality/tpch/q08 | 2 +- .../opt/memo/testdata/stats_quality/tpch/q09 | 2 +- .../opt/memo/testdata/stats_quality/tpch/q10 | 2 +- .../opt/memo/testdata/stats_quality/tpch/q11 | 2 +- .../opt/memo/testdata/stats_quality/tpch/q12 | 2 +- .../opt/memo/testdata/stats_quality/tpch/q13 | 2 +- .../opt/memo/testdata/stats_quality/tpch/q14 | 2 +- .../opt/memo/testdata/stats_quality/tpch/q15 | 2 +- .../opt/memo/testdata/stats_quality/tpch/q16 | 2 +- .../opt/memo/testdata/stats_quality/tpch/q17 | 2 +- .../opt/memo/testdata/stats_quality/tpch/q18 | 2 +- .../opt/memo/testdata/stats_quality/tpch/q19 | 2 +- .../opt/memo/testdata/stats_quality/tpch/q20 | 2 +- .../opt/memo/testdata/stats_quality/tpch/q21 | 2 +- .../opt/memo/testdata/stats_quality/tpch/q22 | 2 +- pkg/sql/opt/norm/testdata/rules/ordering | 4 +- .../opt/optbuilder/testdata/fk-checks-delete | 2 +- .../opt/optbuilder/testdata/fk-checks-insert | 2 +- .../opt/optbuilder/testdata/fk-checks-update | 2 +- pkg/sql/opt/optbuilder/testdata/orderby | 14 +-- .../testdata/propagate-input-ordering | 18 ++-- pkg/sql/opt/testutils/opttester/opt_tester.go | 90 ++----------------- .../opttester/testdata/explore-trace | 2 +- .../opttester/testdata/use-multi-col-stats | 4 +- pkg/sql/opt/xform/testdata/coster/join | 2 +- pkg/sql/opt/xform/testdata/rules/join | 14 +-- pkg/sql/opt/xform/testdata/rules/join_order | 24 ++--- 35 files changed, 96 insertions(+), 176 deletions(-) diff --git a/pkg/sql/opt/memo/testdata/stats_quality/tpcc b/pkg/sql/opt/memo/testdata/stats_quality/tpcc index d2d34bf4546f..105fa1a6e2ea 100644 --- a/pkg/sql/opt/memo/testdata/stats_quality/tpcc +++ b/pkg/sql/opt/memo/testdata/stats_quality/tpcc @@ -15,7 +15,7 @@ import file=tpcc_stats_w10 # reflect on-line database activity as typically found in production # environments. # -------------------------------------------------- -stats-quality format=hide-qual database=tpcc stats-quality-prefix=new_order_01 ignore-tables=1 +stats-quality format=hide-qual database=tpcc set=save_tables_prefix=new_order_01 ignore-tables=1 SELECT w_tax FROM warehouse WHERE w_id = 1 ---- ---- @@ -46,7 +46,7 @@ column_names row_count_est row_count_err distinct_count_est distinct_count_e ---- ---- -stats-quality format=hide-qual database=tpcc stats-quality-prefix=new_order_02 ignore-tables=1 +stats-quality format=hide-qual database=tpcc set=save_tables_prefix=new_order_02 ignore-tables=1 SELECT c_discount, c_last, c_credit FROM customer WHERE c_w_id = 1 AND c_d_id = 1 AND c_id = 50 @@ -87,7 +87,7 @@ column_names row_count_est row_count_err distinct_count_est distinct_count_e ---- ---- -stats-quality format=hide-qual database=tpcc stats-quality-prefix=new_order_03 +stats-quality format=hide-qual database=tpcc set=save_tables_prefix=new_order_03 SELECT i_price, i_name, i_data FROM item WHERE i_id IN (125, 150, 175, 200, 25, 50, 75, 100, 225, 250, 275, 300) @@ -131,7 +131,7 @@ column_names row_count_est row_count_err distinct_count_est distinct_count_e ---- ---- -stats-quality format=hide-qual database=tpcc stats-quality-prefix=new_order_04 ignore-tables=1 +stats-quality format=hide-qual database=tpcc set=save_tables_prefix=new_order_04 ignore-tables=1 SELECT s_quantity, s_ytd, s_order_cnt, s_remote_cnt, s_data, s_dist_05 FROM stock WHERE (s_i_id, s_w_id) IN ((1000, 4), (900, 4), (1100, 4), (1500, 4), (1400, 4)) @@ -193,7 +193,7 @@ column_names row_count_est row_count_err distinct_count_est distinct_count # stringent response time requirements to satisfy on-line users. In addition, # this transaction includes non-primary key access to the CUSTOMER table. # -------------------------------------------------- -stats-quality format=hide-qual database=tpcc stats-quality-prefix=payment_01 ignore-tables=1 +stats-quality format=hide-qual database=tpcc set=save_tables_prefix=payment_01 ignore-tables=1 SELECT c_id FROM customer WHERE c_w_id = 1 AND c_d_id = 1 AND c_last = 'ANTIABLEABLE' @@ -248,7 +248,7 @@ column_names row_count_est row_count_err distinct_count_est distinct_count_e # users. In addition, this table includes non-primary key access to the # CUSTOMER table. # -------------------------------------------------- -stats-quality format=hide-qual database=tpcc stats-quality-prefix=order_status_01 ignore-tables=1 +stats-quality format=hide-qual database=tpcc set=save_tables_prefix=order_status_01 ignore-tables=1 SELECT c_balance, c_first, c_middle, c_last FROM customer WHERE c_w_id = 1 AND c_d_id = 1 AND c_id = 50 @@ -291,7 +291,7 @@ column_names row_count_est row_count_err distinct_count_est distinct_count_e ---- ---- -stats-quality format=hide-qual database=tpcc stats-quality-prefix=order_status_02 ignore-tables=(1,3) +stats-quality format=hide-qual database=tpcc set=save_tables_prefix=order_status_02 ignore-tables=(1,3) SELECT c_id, c_balance, c_first, c_middle FROM customer WHERE c_w_id = 2 AND c_d_id = 2 AND c_last = 'ANTIBARESE' @@ -358,7 +358,7 @@ column_names row_count_est row_count_err distinct_count_est distinct_count_e ---- ---- -stats-quality format=hide-qual database=tpcc stats-quality-prefix=order_status_03 ignore-tables=1 +stats-quality format=hide-qual database=tpcc set=save_tables_prefix=order_status_03 ignore-tables=1 SELECT o_id, o_entry_d, o_carrier_id FROM "order" WHERE o_w_id = 4 AND o_d_id = 3 AND o_c_id = 10 @@ -401,7 +401,7 @@ column_names row_count_est row_count_err distinct_count_est distinct_count ---- ---- -stats-quality format=hide-qual database=tpcc stats-quality-prefix=order_status_04 ignore-tables=1 +stats-quality format=hide-qual database=tpcc set=save_tables_prefix=order_status_04 ignore-tables=1 SELECT ol_i_id, ol_supply_w_id, ol_quantity, ol_amount, ol_delivery_d FROM order_line WHERE ol_w_id = 1 AND ol_d_id = 1 AND ol_o_id = 1000 @@ -463,7 +463,7 @@ column_names row_count_est row_count_err distinct_count_est distinct_cou # indicating transaction completion. The result of the deferred execution is # recorded into a result file. # -------------------------------------------------- -stats-quality format=hide-qual database=tpcc stats-quality-prefix=delivery_01 ignore-tables=1 +stats-quality format=hide-qual database=tpcc set=save_tables_prefix=delivery_01 ignore-tables=1 SELECT no_o_id FROM new_order WHERE no_w_id = 7 AND no_d_id = 6 @@ -500,7 +500,7 @@ column_names row_count_est row_count_err distinct_count_est distinct_count_e ---- ---- -stats-quality format=hide-qual database=tpcc stats-quality-prefix=delivery_02 +stats-quality format=hide-qual database=tpcc set=save_tables_prefix=delivery_02 SELECT sum(ol_amount) FROM order_line WHERE ol_w_id = 8 AND ol_d_id = 6 AND ol_o_id = 1000 @@ -559,7 +559,7 @@ column_names row_count_est row_count_err distinct_count_est distinct_count_e # heavy read-only database transaction with a low frequency of execution, a # relaxed response time requirement, and relaxed consistency requirements. # -------------------------------------------------- -stats-quality format=hide-qual database=tpcc stats-quality-prefix=stock_level_01 ignore-tables=1 +stats-quality format=hide-qual database=tpcc set=save_tables_prefix=stock_level_01 ignore-tables=1 SELECT d_next_o_id FROM district WHERE d_w_id = 4 AND d_id = 9 @@ -594,7 +594,7 @@ column_names row_count_est row_count_err distinct_count_est distinct_count_ ---- ---- -stats-quality format=hide-qual database=tpcc stats-quality-prefix=stock_level_02 +stats-quality format=hide-qual database=tpcc set=save_tables_prefix=stock_level_02 SELECT count(DISTINCT s_i_id) FROM order_line JOIN stock @@ -697,7 +697,7 @@ column_names row_count_est row_count_err distinct_count_est distinct_count_e # These queries run after TPCC in order to check database consistency. # They are not part of the benchmark itself. # -------------------------------------------------- -stats-quality format=hide-qual database=tpcc stats-quality-prefix=consistency_01 +stats-quality format=hide-qual database=tpcc set=save_tables_prefix=consistency_01 SELECT count(*) FROM warehouse FULL OUTER JOIN @@ -812,7 +812,7 @@ column_names row_count_est row_count_err distinct_count_est distinct_count_e ---- ---- -stats-quality format=hide-qual database=tpcc stats-quality-prefix=consistency_02 +stats-quality format=hide-qual database=tpcc set=save_tables_prefix=consistency_02 SELECT d_next_o_id FROM district ORDER BY d_w_id, d_id @@ -845,7 +845,7 @@ column_names row_count_est row_count_err distinct_count_est distinct_count_ ---- ---- -stats-quality format=hide-qual database=tpcc stats-quality-prefix=consistency_03 +stats-quality format=hide-qual database=tpcc set=save_tables_prefix=consistency_03 SELECT max(no_o_id) FROM new_order GROUP BY no_d_id, no_w_id @@ -900,7 +900,7 @@ column_names row_count_est row_count_err distinct_count_est distinct_count_e ---- ---- -stats-quality format=hide-qual database=tpcc stats-quality-prefix=consistency_04 +stats-quality format=hide-qual database=tpcc set=save_tables_prefix=consistency_04 SELECT max(o_id) FROM "order" GROUP BY o_d_id, o_w_id @@ -955,7 +955,7 @@ column_names row_count_est row_count_err distinct_count_est distinct_count_e ---- ---- -stats-quality format=hide-qual database=tpcc stats-quality-prefix=consistency_05 +stats-quality format=hide-qual database=tpcc set=save_tables_prefix=consistency_05 SELECT count(*) FROM ( @@ -1062,7 +1062,7 @@ column_names row_count_est row_count_err distinct_count_est distinct_count_e ---- ---- -stats-quality format=hide-qual database=tpcc stats-quality-prefix=consistency_06 +stats-quality format=hide-qual database=tpcc set=save_tables_prefix=consistency_06 SELECT sum(o_ol_cnt) FROM "order" GROUP BY o_w_id, o_d_id @@ -1116,7 +1116,7 @@ column_names row_count_est row_count_err distinct_count_est distinct_count_e ---- ---- -stats-quality format=hide-qual database=tpcc stats-quality-prefix=consistency_07 +stats-quality format=hide-qual database=tpcc set=save_tables_prefix=consistency_07 SELECT count(*) FROM order_line GROUP BY ol_w_id, ol_d_id @@ -1165,7 +1165,7 @@ column_names row_count_est row_count_err distinct_count_est distinct_count_e ---- ---- -stats-quality format=hide-qual database=tpcc stats-quality-prefix=consistency_08 +stats-quality format=hide-qual database=tpcc set=save_tables_prefix=consistency_08 (SELECT no_w_id, no_d_id, no_o_id FROM new_order) EXCEPT ALL (SELECT o_w_id, o_d_id, o_id FROM "order" WHERE o_carrier_id IS NULL) @@ -1280,7 +1280,7 @@ column_names row_count_est row_count_err distinct_count_est distinct_count ---- ---- -stats-quality format=hide-qual database=tpcc stats-quality-prefix=consistency_09 +stats-quality format=hide-qual database=tpcc set=save_tables_prefix=consistency_09 (SELECT o_w_id, o_d_id, o_id FROM "order" WHERE o_carrier_id IS NULL) EXCEPT ALL (SELECT no_w_id, no_d_id, no_o_id FROM new_order) @@ -1395,7 +1395,7 @@ column_names row_count_est row_count_err distinct_count_est distinct_count_e ---- ---- -stats-quality format=hide-qual database=tpcc stats-quality-prefix=consistency_10 +stats-quality format=hide-qual database=tpcc set=save_tables_prefix=consistency_10 ( SELECT o_w_id, o_d_id, o_id, o_ol_cnt FROM "order" @@ -1508,7 +1508,7 @@ column_names row_count_est row_count_err distinct_count_est distinct_count_e ---- ---- -stats-quality format=hide-qual database=tpcc stats-quality-prefix=consistency_11 +stats-quality format=hide-qual database=tpcc set=save_tables_prefix=consistency_11 ( SELECT ol_w_id, ol_d_id, ol_o_id, count(*) FROM order_line @@ -1621,7 +1621,7 @@ column_names row_count_est row_count_err distinct_count_est distinct_count_e ---- ---- -stats-quality database=tpcc stats-quality-prefix=consistency_12 +stats-quality database=tpcc set=save_tables_prefix=consistency_12 SELECT count(*) FROM ( diff --git a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q01 b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q01 index 61255730a94f..584f678ec7bc 100644 --- a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q01 +++ b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q01 @@ -17,7 +17,7 @@ import file=tpch_stats # LINESTATUS, and listed in ascending order of RETURNFLAG and LINESTATUS. A # count of the number of lineitems in each group is included. # -------------------------------------------------- -stats-quality database=tpch stats-quality-prefix=q1 +stats-quality database=tpch set=save_tables_prefix=q1 SELECT l_returnflag, l_linestatus, diff --git a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q02 b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q02 index 9a7f21af1218..1f812e93d725 100644 --- a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q02 +++ b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q02 @@ -22,7 +22,7 @@ import file=tpch_stats # 1. Allow Select to be pushed below Ordinality used to add key column # 2. Add decorrelation rule for Ordinality/RowKey # -------------------------------------------------- -stats-quality database=tpch stats-quality-prefix=q2 +stats-quality database=tpch set=save_tables_prefix=q2 SELECT s_acctbal, s_name, diff --git a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q03 b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q03 index 4c9ad01b0b5c..56404c3f93ac 100644 --- a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q03 +++ b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q03 @@ -15,7 +15,7 @@ import file=tpch_stats # decreasing order of revenue. If more than 10 unshipped orders exist, only the # 10 orders with the largest revenue are listed. # -------------------------------------------------- -stats-quality database=tpch stats-quality-prefix=q3 +stats-quality database=tpch set=save_tables_prefix=q3 SELECT l_orderkey, sum(l_extendedprice * (1 - l_discount)) AS revenue, diff --git a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q04 b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q04 index 333593941687..edea9733cd1e 100644 --- a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q04 +++ b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q04 @@ -15,7 +15,7 @@ import file=tpch_stats # committed date. The query lists the count of such orders for each order # priority sorted in ascending priority order. # -------------------------------------------------- -stats-quality database=tpch stats-quality-prefix=q4 +stats-quality database=tpch set=save_tables_prefix=q4 SELECT o_orderpriority, count(*) AS order_count diff --git a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q05 b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q05 index 53ac4608fb32..b6c2d6897d86 100644 --- a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q05 +++ b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q05 @@ -18,7 +18,7 @@ import file=tpch_stats # all qualifying lineitems in a particular nation is defined as # sum(l_extendedprice * (1 - l_discount)). # -------------------------------------------------- -stats-quality database=tpch stats-quality-prefix=q5 +stats-quality database=tpch set=save_tables_prefix=q5 SELECT n_name, sum(l_extendedprice * (1 - l_discount)) AS revenue diff --git a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q06 b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q06 index 171e8f604eaf..07128319a9a8 100644 --- a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q06 +++ b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q06 @@ -19,7 +19,7 @@ import file=tpch_stats # increase is equal to the sum of [l_extendedprice * l_discount] for all # lineitems with discounts and quantities in the qualifying range. # -------------------------------------------------- -stats-quality database=tpch stats-quality-prefix=q6 +stats-quality database=tpch set=save_tables_prefix=q6 SELECT sum(l_extendedprice * l_discount) AS revenue FROM diff --git a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q07 b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q07 index 13660ffdfc36..dbef1be74e76 100644 --- a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q07 +++ b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q07 @@ -17,7 +17,7 @@ import file=tpch_stats # that took place in that year. The query orders the answer by Supplier nation, # Customer nation, and year (all ascending). # -------------------------------------------------- -stats-quality database=tpch stats-quality-prefix=q7 +stats-quality database=tpch set=save_tables_prefix=q7 SELECT supp_nation, cust_nation, diff --git a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q08 b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q08 index b99a99f39204..65b6e4fe5b6d 100644 --- a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q08 +++ b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q08 @@ -16,7 +16,7 @@ import file=tpch_stats # from the given nation. The query determines this for the years 1995 and 1996 # presented in this order. # -------------------------------------------------- -stats-quality database=tpch stats-quality-prefix=q8 +stats-quality database=tpch set=save_tables_prefix=q8 SELECT o_year, sum(CASE diff --git a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q09 b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q09 index 7b05f58c49cf..8f726380849b 100644 --- a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q09 +++ b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q09 @@ -20,7 +20,7 @@ import file=tpch_stats # nations in ascending alphabetical order and, for each nation, the year and # profit in descending order by year (most recent first). # -------------------------------------------------- -stats-quality database=tpch stats-quality-prefix=q9 +stats-quality database=tpch set=save_tables_prefix=q9 SELECT nation, o_year, diff --git a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q10 b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q10 index 4deabbdad3b5..d33a7257b6f8 100644 --- a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q10 +++ b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q10 @@ -18,7 +18,7 @@ import file=tpch_stats # Revenue lost is defined as sum(l_extendedprice*(1-l_discount)) for all # qualifying lineitems. # -------------------------------------------------- -stats-quality database=tpch stats-quality-prefix=q10 +stats-quality database=tpch set=save_tables_prefix=q10 SELECT c_custkey, c_name, diff --git a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q11 b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q11 index 3220ed326d16..3301ce3d091b 100644 --- a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q11 +++ b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q11 @@ -14,7 +14,7 @@ import file=tpch_stats # available parts. The query displays the part number and the value of those # parts in descending order of value. # -------------------------------------------------- -stats-quality database=tpch stats-quality-prefix=q11 +stats-quality database=tpch set=save_tables_prefix=q11 SELECT ps_partkey, sum(ps_supplycost * ps_availqty::float) AS value diff --git a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q12 b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q12 index dad36f16711a..6171822e24c5 100644 --- a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q12 +++ b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q12 @@ -18,7 +18,7 @@ import file=tpch_stats # The late lineitems are partitioned into two groups, those with priority URGENT # or HIGH, and those with a priority other than URGENT or HIGH. # -------------------------------------------------- -stats-quality database=tpch stats-quality-prefix=q12 +stats-quality database=tpch set=save_tables_prefix=q12 SELECT l_shipmode, sum(CASE diff --git a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q13 b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q13 index d229a28d674d..10687b84f333 100644 --- a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q13 +++ b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q13 @@ -15,7 +15,7 @@ import file=tpch_stats # several special categories of orders. Special categories are identified in the # order comment column by looking for a particular pattern. # -------------------------------------------------- -stats-quality database=tpch stats-quality-prefix=q13 +stats-quality database=tpch set=save_tables_prefix=q13 SELECT c_count, count(*) AS custdist FROM ( diff --git a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q14 b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q14 index ad8304c42760..b1e09c48d833 100644 --- a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q14 +++ b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q14 @@ -15,7 +15,7 @@ import file=tpch_stats # shipped in that month and gives the percentage. Revenue is defined as # (l_extendedprice * (1-l_discount)). # -------------------------------------------------- -stats-quality database=tpch stats-quality-prefix=q14 +stats-quality database=tpch set=save_tables_prefix=q14 SELECT 100.00 * sum(CASE WHEN p_type LIKE 'PROMO%' diff --git a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q15 b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q15 index 62c44bbdce73..0a5ccbcc5cb4 100644 --- a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q15 +++ b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q15 @@ -29,7 +29,7 @@ CREATE VIEW revenue0 (supplier_no, total_revenue) AS l_suppkey; ---- -stats-quality database=tpch stats-quality-prefix=q15 +stats-quality database=tpch set=save_tables_prefix=q15 SELECT s_suppkey, s_name, diff --git a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q16 b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q16 index a6f7db54965a..1061a257edb2 100644 --- a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q16 +++ b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q16 @@ -18,7 +18,7 @@ import file=tpch_stats # Business Bureau. Results must be presented in descending count and ascending # brand, type, and size. # -------------------------------------------------- -stats-quality database=tpch stats-quality-prefix=q16 +stats-quality database=tpch set=save_tables_prefix=q16 SELECT p_brand, p_type, diff --git a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q17 b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q17 index 5060704c1e94..4748920c230a 100644 --- a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q17 +++ b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q17 @@ -20,7 +20,7 @@ import file=tpch_stats # TODO: # 1. Allow Select to be pushed below Ordinality used to add key column # -------------------------------------------------- -stats-quality database=tpch stats-quality-prefix=q17 +stats-quality database=tpch set=save_tables_prefix=q17 SELECT sum(l_extendedprice) / 7.0 AS avg_yearly FROM diff --git a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q18 b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q18 index a53a5c51e409..71c7bb0bf306 100644 --- a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q18 +++ b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q18 @@ -15,7 +15,7 @@ import file=tpch_stats # orders. The query lists the customer name, customer key, the order key, date # and total price and the quantity for the order. # -------------------------------------------------- -stats-quality database=tpch stats-quality-prefix=q18 +stats-quality database=tpch set=save_tables_prefix=q18 SELECT c_name, c_custkey, diff --git a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q19 b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q19 index e723b9bf1aa1..ca9dcb59ae0d 100644 --- a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q19 +++ b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q19 @@ -16,7 +16,7 @@ import file=tpch_stats # person. Parts are selected based on the combination of specific brands, a list # of containers, and a range of sizes. # -------------------------------------------------- -stats-quality database=tpch stats-quality-prefix=q19 +stats-quality database=tpch set=save_tables_prefix=q19 SELECT sum(l_extendedprice* (1 - l_discount)) AS revenue FROM diff --git a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q20 b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q20 index b8aecbf97f69..4b467e8a99f4 100644 --- a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q20 +++ b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q20 @@ -18,7 +18,7 @@ import file=tpch_stats # TODO: # 1. Push 'forest%' prefix filter down into Scan # -------------------------------------------------- -stats-quality database=tpch stats-quality-prefix=q20 +stats-quality database=tpch set=save_tables_prefix=q20 SELECT s_name, s_address diff --git a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q21 b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q21 index cacf0bce02e0..5ae94a630b73 100644 --- a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q21 +++ b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q21 @@ -14,7 +14,7 @@ import file=tpch_stats # supplier order (with current status of 'F') where they were the only supplier # who failed to meet the committed delivery date. # -------------------------------------------------- -stats-quality database=tpch stats-quality-prefix=q21 +stats-quality database=tpch set=save_tables_prefix=q21 SELECT s_name, count(*) AS numwait diff --git a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q22 b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q22 index ab53585ea0d8..f259be2ba9a5 100644 --- a/pkg/sql/opt/memo/testdata/stats_quality/tpch/q22 +++ b/pkg/sql/opt/memo/testdata/stats_quality/tpch/q22 @@ -15,7 +15,7 @@ import file=tpch_stats # “positive” account balance. It also reflects the magnitude of that balance. # Country code is defined as the first two characters of c_phone. # -------------------------------------------------- -stats-quality database=tpch stats-quality-prefix=q22 +stats-quality database=tpch set=save_tables_prefix=q22 SELECT cntrycode, count(*) AS numcust, diff --git a/pkg/sql/opt/norm/testdata/rules/ordering b/pkg/sql/opt/norm/testdata/rules/ordering index 2a602c4202d6..02112e815b80 100644 --- a/pkg/sql/opt/norm/testdata/rules/ordering +++ b/pkg/sql/opt/norm/testdata/rules/ordering @@ -246,7 +246,7 @@ project # -------------------------------------------------- # SimplifyWithBindingOrdering # -------------------------------------------------- -norm propagate-input-ordering expect=SimplifyWithBindingOrdering +norm set=propagate_input_ordering=true expect=SimplifyWithBindingOrdering WITH cte AS (SELECT a, b FROM abcde ORDER BY a, b, c) SELECT * FROM cte, xyz ---- @@ -277,7 +277,7 @@ with &1 (cte) │ └── fd: (10)-->(11,12) └── filters (true) -norm propagate-input-ordering expect=SimplifyWithBindingOrdering +norm set=propagate_input_ordering=true expect=SimplifyWithBindingOrdering WITH cte AS (SELECT d, 1 AS one, e FROM abcde ORDER BY d, one, e) SELECT * FROM cte ---- diff --git a/pkg/sql/opt/optbuilder/testdata/fk-checks-delete b/pkg/sql/opt/optbuilder/testdata/fk-checks-delete index dde80065ff05..324fa0c55a6c 100644 --- a/pkg/sql/opt/optbuilder/testdata/fk-checks-delete +++ b/pkg/sql/opt/optbuilder/testdata/fk-checks-delete @@ -140,7 +140,7 @@ delete doublechild └── p1:7 = 10 # Verify that the join hint is set. -build prefer-lookup-joins-for-fks +build set=prefer_lookup_joins_for_fks=true DELETE FROM parent WHERE p = 3 ---- delete parent diff --git a/pkg/sql/opt/optbuilder/testdata/fk-checks-insert b/pkg/sql/opt/optbuilder/testdata/fk-checks-insert index a6e0c5961e91..6abb42dc9f79 100644 --- a/pkg/sql/opt/optbuilder/testdata/fk-checks-insert +++ b/pkg/sql/opt/optbuilder/testdata/fk-checks-insert @@ -657,7 +657,7 @@ insert multi_ref_child └── (1, NULL, NULL, NULL) # Verify that the join hint is set. -build prefer-lookup-joins-for-fks +build set=prefer_lookup_joins_for_fks=true INSERT INTO child VALUES (100, 1), (200, 1) ---- insert child diff --git a/pkg/sql/opt/optbuilder/testdata/fk-checks-update b/pkg/sql/opt/optbuilder/testdata/fk-checks-update index 229d11bd385f..34248f2f540c 100644 --- a/pkg/sql/opt/optbuilder/testdata/fk-checks-update +++ b/pkg/sql/opt/optbuilder/testdata/fk-checks-update @@ -541,7 +541,7 @@ update fam └── d:19 = two.b:21 # Verify that the join hint is set. -build prefer-lookup-joins-for-fks +build set=prefer_lookup_joins_for_fks=true UPDATE child SET p = 4 ---- update child diff --git a/pkg/sql/opt/optbuilder/testdata/orderby b/pkg/sql/opt/optbuilder/testdata/orderby index bd394125cfbe..29216a9b64d2 100644 --- a/pkg/sql/opt/optbuilder/testdata/orderby +++ b/pkg/sql/opt/optbuilder/testdata/orderby @@ -1091,7 +1091,7 @@ sort # Try NULLS ordered last. # Next two plans should be the same. -build null-ordered-last +build set=null_ordered_last=true SELECT a, b FROM abcd ORDER BY b, c ---- sort @@ -1105,7 +1105,7 @@ sort ├── b:2 IS NULL [as=nulls_ordering_b:7] └── c:3 IS NULL [as=nulls_ordering_c:8] -build null-ordered-last +build set=null_ordered_last=true SELECT a, b FROM abcd ORDER BY b, c NULLS LAST ---- sort @@ -1120,7 +1120,7 @@ sort └── c:3 IS NULL [as=nulls_ordering_c:8] # Should be different from the plan above (1 null re-ordering). -build null-ordered-last +build set=null_ordered_last=true SELECT a, b FROM abcd ORDER BY b NULLS FIRST, c ---- sort @@ -1134,7 +1134,7 @@ sort └── c:3 IS NULL [as=nulls_ordering_c:7] # Should be different from the two plans above (2 null re-orderings). -build null-ordered-last +build set=null_ordered_last=true SELECT a, b FROM abcd ORDER BY b NULLS FIRST, c DESC NULLS LAST ---- sort @@ -1218,7 +1218,7 @@ sort # Try with NULL ordered last. # Next two plans should be the same. -build null-ordered-last +build set=null_ordered_last=true SELECT * FROM abcd ORDER BY b DESC ---- sort @@ -1231,7 +1231,7 @@ sort └── projections └── b:2 IS NULL [as=nulls_ordering_b:7] -build null-ordered-last +build set=null_ordered_last=true SELECT * FROM abcd ORDER BY b DESC NULLS FIRST ---- sort @@ -1245,7 +1245,7 @@ sort └── b:2 IS NULL [as=nulls_ordering_b:7] # Should be different from the plan above (1 null re-ordering). -build null-ordered-last +build set=null_ordered_last=true SELECT * FROM abcd ORDER BY b DESC NULLS LAST ---- sort diff --git a/pkg/sql/opt/optbuilder/testdata/propagate-input-ordering b/pkg/sql/opt/optbuilder/testdata/propagate-input-ordering index 47c75ef8db45..90b24db52639 100644 --- a/pkg/sql/opt/optbuilder/testdata/propagate-input-ordering +++ b/pkg/sql/opt/optbuilder/testdata/propagate-input-ordering @@ -8,7 +8,7 @@ exec-ddl CREATE TABLE xy (x int, y int); ---- -build propagate-input-ordering +build set=propagate_input_ordering=true SELECT * FROM (SELECT * FROM generate_series(1, 10) i ORDER BY i % 5 ASC, i ASC) ---- @@ -26,7 +26,7 @@ sort └── projections └── generate_series:1 % 5 [as=column2:2] -build propagate-input-ordering +build set=propagate_input_ordering=true WITH tmp AS (SELECT * FROM generate_series(1, 10) i ORDER BY i % 5 ASC, i ASC) SELECT * FROM tmp; ---- with &1 (tmp) @@ -51,7 +51,7 @@ with &1 (tmp) └── generate_series:1 => i:3 # The internal ordering column for i%5 should not be present in the output. -build propagate-input-ordering +build set=propagate_input_ordering=true SELECT foo FROM (SELECT i, i%2 FROM generate_series(1, 10) i ORDER BY i % 5 ASC, i ASC) AS foo ---- sort @@ -74,7 +74,7 @@ sort └── ((generate_series:1, "?column?":2) AS i, "?column?") [as=foo:4] # The internal ordering column for i%5 should not be present in the output. -build propagate-input-ordering +build set=propagate_input_ordering=true SELECT foo.* FROM (SELECT i, i%2 FROM generate_series(1, 10) i ORDER BY i % 5 ASC, i ASC) AS foo ---- sort @@ -93,7 +93,7 @@ sort └── generate_series:1 % 5 [as=column3:3] # The subquery ordering is propagated to the aggregation. -build propagate-input-ordering +build set=propagate_input_ordering=true SELECT array_agg(i) FROM (SELECT * FROM generate_series(1, 5) i ORDER BY i%2 DESC, i) ---- scalar-group-by @@ -117,7 +117,7 @@ scalar-group-by └── generate_series:1 # The input ordering is not propagated through joins. -build propagate-input-ordering +build set=propagate_input_ordering=true SELECT * FROM (SELECT * FROM generate_series(1, 2) x) tmp, (SELECT * FROM generate_series(8, 12) i ORDER BY i % 5 ASC, i ASC) tmp2; @@ -144,7 +144,7 @@ inner-join (cross) # Do not preserve the subquery ordering because the parent scope has its own # ordering. -build propagate-input-ordering +build set=propagate_input_ordering=true SELECT * FROM (SELECT * FROM generate_series(1, 10) i ORDER BY i % 5 ASC, i ASC) ORDER BY i DESC; @@ -166,7 +166,7 @@ sort └── generate_series:1 % 5 [as=column2:2] # CTEs get materialized in the desired order. -build propagate-input-ordering +build set=propagate_input_ordering=true WITH cte1 AS (SELECT b FROM ab ORDER BY a, b), cte2 AS (SELECT y FROM xy ORDER BY x, y) @@ -205,7 +205,7 @@ with &1 (cte1) └── mapping: └── xy.y:7 => y:12 -build propagate-input-ordering +build set=propagate_input_ordering=true WITH cte1 AS (SELECT b FROM ab), cte2 AS (SELECT DISTINCT ON (x) y FROM xy ORDER BY x, y) diff --git a/pkg/sql/opt/testutils/opttester/opt_tester.go b/pkg/sql/opt/testutils/opttester/opt_tester.go index 7911d4f9a83e..2bf6af53efac 100644 --- a/pkg/sql/opt/testutils/opttester/opt_tester.go +++ b/pkg/sql/opt/testutils/opttester/opt_tester.go @@ -181,21 +181,10 @@ type Flags struct { // the coster will be in the range [c - 0.5 * c, c + 0.5 * c). PerturbCost float64 - // JoinLimit is the default value for SessionData.ReorderJoinsLimit. - JoinLimit int - // PreferLookupJoinsForFK is the default value for // SessionData.PreferLookupJoinsForFKs. PreferLookupJoinsForFKs bool - // PropagateInputOrdering is the default value for - // SessionData.PropagateInputOrdering. - PropagateInputOrdering bool - - // NullOrderedLast is the default value for - // SessionData.NullOrderedLast. - NullOrderedLast bool - // Locality specifies the location of the planning node as a set of user- // defined key/value pairs, ordered from most inclusive to least inclusive. // If there are no tiers, then the node's location is not known. Examples: @@ -213,10 +202,6 @@ type Flags struct { // only used by the inject-stats commands. Table string - // SaveTablesPrefix specifies the prefix of the table to create or print - // for each subexpression in the query. - SaveTablesPrefix string - // IgnoreTables specifies the subset of stats tables which should not be // outputted by the stats-quality command. IgnoreTables util.FastIntSet @@ -259,10 +244,6 @@ type Flags struct { // QueryArgs are values for placeholders, used for assign-placeholders-*. QueryArgs []string - // UseMultiColStats is the value for SessionData.OptimizerUseMultiColStats. - // It defaults to true in New. - UseMultiColStats bool - // SkipRace indicates that a test should be skipped if the race detector is // enabled. SkipRace bool @@ -276,13 +257,15 @@ type Flags struct { func New(catalog cat.Catalog, sql string) *OptTester { ctx := context.Background() ot := &OptTester{ - Flags: Flags{JoinLimit: opt.DefaultJoinOrderLimit, UseMultiColStats: true}, + Flags: Flags{}, catalog: catalog, sql: sql, ctx: ctx, semaCtx: tree.MakeSemaContext(), evalCtx: eval.MakeTestingEvalContext(cluster.MakeTestingClusterSettings()), } + ot.evalCtx.SessionData().ReorderJoinsLimit = opt.DefaultJoinOrderLimit + ot.evalCtx.SessionData().OptimizerUseMultiColStats = true ot.Flags.ot = ot ot.semaCtx.SearchPath = tree.EmptySearchPath ot.semaCtx.FunctionResolver = ot.catalog @@ -513,16 +496,6 @@ func New(catalog cat.Catalog, sql string) *OptTester { // - import: the file path is relative to opttester/testfixtures; // - inject-stats: the file path is relative to the test file. // -// - join-limit: sets the value for SessionData.ReorderJoinsLimit, which -// indicates the number of joins at which the optimizer should stop -// attempting to reorder. -// -// - prefer-lookup-joins-for-fks: sets SessionData.PreferLookupJoinsForFKs to -// true, causing foreign key operations to prefer lookup joins. -// -// - null-ordered-last: sets SessionData.NullOrderedLast to true, which orders -// NULL values last in ascending order. -// // - cascade-levels: used to limit the depth of recursive cascades for // build-cascades. // @@ -543,11 +516,6 @@ func New(catalog cat.Catalog, sql string) *OptTester { // - memo-cycles: used with memo to search the memo for cycles and output a // path with a cycle if one is found. // -// - use-multi-col-stats: sets the value for -// SessionData.OptimizerUseMultiColStats which indicates whether or not -// multi-column statistics are used for cardinality estimation in the -// optimizer. This option requires a single boolean argument. -// // - skip-race: skips the test if the race detector is enabled. // func (ot *OptTester) RunCommand(tb testing.TB, d *datadriven.TestData) string { @@ -567,15 +535,8 @@ func (ot *OptTester) RunCommand(tb testing.TB, d *datadriven.TestData) string { ot.semaCtx.Placeholders = tree.PlaceholderInfo{} - ot.evalCtx.SessionData().ReorderJoinsLimit = int64(ot.Flags.JoinLimit) - ot.evalCtx.SessionData().PreferLookupJoinsForFKs = ot.Flags.PreferLookupJoinsForFKs - ot.evalCtx.SessionData().PropagateInputOrdering = ot.Flags.PropagateInputOrdering - ot.evalCtx.SessionData().NullOrderedLast = ot.Flags.NullOrderedLast - ot.evalCtx.SessionData().OptimizerUseMultiColStats = ot.Flags.UseMultiColStats - ot.evalCtx.TestingKnobs.OptimizerCostPerturbation = ot.Flags.PerturbCost ot.evalCtx.Locality = ot.Flags.Locality - ot.evalCtx.SessionData().SaveTablesPrefix = ot.Flags.SaveTablesPrefix ot.evalCtx.Placeholders = nil switch d.Cmd { @@ -954,28 +915,6 @@ func (f *Flags) Set(arg datadriven.CmdArg) error { f.DisableRules.Add(int(r)) } - case "join-limit": - if len(arg.Vals) != 1 { - return fmt.Errorf("join-limit requires a single argument") - } - limit, err := strconv.ParseInt(arg.Vals[0], 10, 64) - if err != nil { - return errors.Wrap(err, "join-limit") - } - f.JoinLimit = int(limit) - - case "prefer-lookup-joins-for-fks": - if len(arg.Vals) > 0 { - return fmt.Errorf("unknown vals for prefer-lookup-joins-for-fks") - } - f.PreferLookupJoinsForFKs = true - - case "null-ordered-last": - if len(arg.Vals) > 0 { - return fmt.Errorf("unknown vals for null-ordered-last") - } - f.NullOrderedLast = true - case "rule": if len(arg.Vals) != 1 { return fmt.Errorf("rule requires one argument") @@ -1047,12 +986,6 @@ func (f *Flags) Set(arg datadriven.CmdArg) error { } f.Table = arg.Vals[0] - case "stats-quality-prefix": - if len(arg.Vals) != 1 { - return fmt.Errorf("stats-quality-prefix requires one argument") - } - f.SaveTablesPrefix = arg.Vals[0] - case "ignore-tables": var tables util.FastIntSet addTables := func(val string) error { @@ -1137,19 +1070,6 @@ func (f *Flags) Set(arg datadriven.CmdArg) error { case "query-args": f.QueryArgs = arg.Vals - case "propagate-input-ordering": - f.PropagateInputOrdering = true - - case "use-multi-col-stats": - if len(arg.Vals) != 1 { - return fmt.Errorf("use-multi-col-stats requires a single argument") - } - b, err := strconv.ParseBool(arg.Vals[0]) - if err != nil { - return errors.Wrap(err, "use-multi-col-stats") - } - f.UseMultiColStats = b - case "memo-cycles": f.MemoFormat = xform.FmtCycle @@ -1924,7 +1844,7 @@ func (ot *OptTester) StatsQuality(tb testing.TB, d *datadriven.TestData) (string // tree. Keep track of the name of each table so that stats can be outputted // later. var names []string - nameGen := memo.NewExprNameGenerator(ot.Flags.SaveTablesPrefix) + nameGen := memo.NewExprNameGenerator(ot.evalCtx.SessionData().SaveTablesPrefix) var traverse func(e opt.Expr) error traverse = func(e opt.Expr) error { if r, ok := e.(memo.RelExpr); ok { @@ -2020,7 +1940,7 @@ func (ot *OptTester) saveActualTables() error { } if _, err := c.ExecContext(ctx, - fmt.Sprintf("SET save_tables_prefix = '%s'", ot.Flags.SaveTablesPrefix), + fmt.Sprintf("SET save_tables_prefix = '%s'", ot.evalCtx.SessionData().SaveTablesPrefix), ); err != nil { return err } diff --git a/pkg/sql/opt/testutils/opttester/testdata/explore-trace b/pkg/sql/opt/testutils/opttester/testdata/explore-trace index d44a8ef4be10..7497be623f23 100644 --- a/pkg/sql/opt/testutils/opttester/testdata/explore-trace +++ b/pkg/sql/opt/testutils/opttester/testdata/explore-trace @@ -125,7 +125,7 @@ CREATE TABLE grandchild ( ---- # Regression test for 36225. -exploretrace join-limit=3 rule=ReorderJoins skip-no-op format=hide-all +exploretrace set=reorder_joins_limit=3 rule=ReorderJoins skip-no-op format=hide-all SELECT * FROM grandchild JOIN child USING (pid, cid) diff --git a/pkg/sql/opt/testutils/opttester/testdata/use-multi-col-stats b/pkg/sql/opt/testutils/opttester/testdata/use-multi-col-stats index 92e3091c4075..a99ce6d78251 100644 --- a/pkg/sql/opt/testutils/opttester/testdata/use-multi-col-stats +++ b/pkg/sql/opt/testutils/opttester/testdata/use-multi-col-stats @@ -21,7 +21,7 @@ CREATE TABLE rides ( inject-stats file=inject-stats.json table=rides ---- -opt format=show-stats use-multi-col-stats=true +opt format=show-stats set=optimizer_use_multicol_stats=true SELECT * FROM rides WHERE city = 'rome' and id = '17198184-b24f-4aa8-9933-64a72ff6665f' ---- scan rides @@ -32,7 +32,7 @@ scan rides ├── key: () └── fd: ()-->(1-10) -opt format=show-stats use-multi-col-stats=false +opt format=show-stats set=optimizer_use_multicol_stats=false SELECT * FROM rides WHERE city = 'rome' and id = '17198184-b24f-4aa8-9933-64a72ff6665f' ---- scan rides diff --git a/pkg/sql/opt/xform/testdata/coster/join b/pkg/sql/opt/xform/testdata/coster/join index 0ab1d4726d00..e3982614a2a3 100644 --- a/pkg/sql/opt/xform/testdata/coster/join +++ b/pkg/sql/opt/xform/testdata/coster/join @@ -811,7 +811,7 @@ insert c └── filters (true) # The cost should be much smaller with this hint. -opt prefer-lookup-joins-for-fks +opt set=prefer_lookup_joins_for_fks=true INSERT INTO c VALUES (1,1), (2,2) ---- insert c diff --git a/pkg/sql/opt/xform/testdata/rules/join b/pkg/sql/opt/xform/testdata/rules/join index 780562503f9d..1ddc6578fd9d 100644 --- a/pkg/sql/opt/xform/testdata/rules/join +++ b/pkg/sql/opt/xform/testdata/rules/join @@ -330,7 +330,7 @@ memo (optimized, ~28KB, required=[presentation: a:1,b:2,c:3,s:7,t:8,u:9,x:12,y:1 # Joins that exceed reorder_joins_limit are not reordered apart from # commutation. -memo join-limit=1 +memo set=reorder_joins_limit=1 SELECT * FROM stu, abc, xyz, pqr WHERE u = a AND a = x AND x = p @@ -1375,7 +1375,7 @@ memo (optimized, ~12KB, required=[presentation: a:1,b:2,c:3,x:7,y:8,z:9]) └── G8: (variable x) # Verify that setting the join limit to 1 allows only commutation. -exploretrace rule=ReorderJoins format=hide-all join-limit=1 +exploretrace rule=ReorderJoins format=hide-all set=reorder_joins_limit=1 SELECT * FROM abc INNER JOIN stu ON s = a INNER JOIN xyz ON s = x @@ -9950,7 +9950,7 @@ memo (optimized, ~21KB, required=[presentation: ?column?:7]) ├── G15: (tuple G16) └── G16: (scalar-list) -opt join-limit=3 +opt set=reorder_joins_limit=3 SELECT false FROM @@ -9991,7 +9991,7 @@ with &1 ├── key: () └── fd: ()-->(30) -opt join-limit=3 +opt set=reorder_joins_limit=3 SELECT 1 FROM ((VALUES (1), (1)) JOIN ((VALUES (1), (1), (1)) JOIN (VALUES (1), (1), (1), (1)) ON true) ON true) UNION ALL SELECT 1 FROM ((VALUES (1), (1)) JOIN (VALUES (1), (1), (1)) ON true) JOIN (VALUES (1), (1), (1), (1)) ON true @@ -11594,7 +11594,7 @@ semi-join (lookup abc_part@c_idx) # NOTE: A locality optimized lookup join is possible here after the join has # been reordered (because d is a lax key), so we prevent reordering to test this # case and ensure the expect-not holds. -opt locality=(region=east) expect-not=GenerateLocalityOptimizedLookupJoin join-limit=0 +opt locality=(region=east) expect-not=GenerateLocalityOptimizedLookupJoin set=reorder_joins_limit=0 SELECT * FROM def_part WHERE EXISTS (SELECT * FROM abc_part WHERE f = c AND e % a = 0) AND d = 10 ---- semi-join (lookup abc_part@c_idx) @@ -11638,7 +11638,7 @@ semi-join (lookup abc_part@c_idx) # NOTE: A locality optimized lookup join is possible here after the join has # been reordered (because d is a lax key), so we prevent reordering to test this # case and ensure the expect-not holds. -opt locality=(region=east) expect-not=GenerateLocalityOptimizedLookupJoin join-limit=0 +opt locality=(region=east) expect-not=GenerateLocalityOptimizedLookupJoin set=reorder_joins_limit=0 SELECT * FROM def_part INNER JOIN abc_part ON f = c WHERE d = 10 ---- project @@ -11746,7 +11746,7 @@ anti-join (lookup abc_part) # NOTE: A locality optimized lookup join is possible here after the join has # been reordered, so we prevent reordering to test this case and ensure the # expect-not holds. -opt locality=(region=east) expect-not=GenerateLocalityOptimizedLookupJoin join-limit=0 +opt locality=(region=east) expect-not=GenerateLocalityOptimizedLookupJoin set=reorder_joins_limit=0 SELECT * FROM def_part INNER JOIN abc_part ON f = v WHERE d = 1 ---- inner-join (lookup abc_part) diff --git a/pkg/sql/opt/xform/testdata/rules/join_order b/pkg/sql/opt/xform/testdata/rules/join_order index 5a4dd2ee02b2..72b3ebf9940d 100644 --- a/pkg/sql/opt/xform/testdata/rules/join_order +++ b/pkg/sql/opt/xform/testdata/rules/join_order @@ -28,7 +28,7 @@ CREATE TABLE abc ( ) ---- -opt join-limit=2 expect=ReorderJoins +opt set=reorder_joins_limit=2 expect=ReorderJoins SELECT * FROM abc, bx, cy WHERE a = 1 AND abc.b = bx.b AND abc.c = cy.c ---- inner-join (lookup cy) @@ -54,7 +54,7 @@ inner-join (lookup cy) │ └── filters (true) └── filters (true) -opt join-limit=2 expect=ReorderJoins +opt set=reorder_joins_limit=2 expect=ReorderJoins SELECT * FROM bx, abc, cy WHERE a = 1 AND abc.b = bx.b AND abc.c = cy.c ---- inner-join (lookup bx) @@ -80,7 +80,7 @@ inner-join (lookup bx) │ └── filters (true) └── filters (true) -opt join-limit=2 expect=ReorderJoins +opt set=reorder_joins_limit=2 expect=ReorderJoins SELECT * FROM bx, cy, abc WHERE a = 1 AND abc.b = bx.b AND abc.c = cy.c ---- inner-join (lookup bx) @@ -107,7 +107,7 @@ inner-join (lookup bx) └── filters (true) # Reorder subtrees of size 2. -exploretrace join-limit=2 rule=ReorderJoins format=hide-all +exploretrace set=reorder_joins_limit=2 rule=ReorderJoins format=hide-all SELECT * FROM bx, cy, dz, abc WHERE a = 1 AND abc.b = bx.b AND abc.c = cy.c AND cy.c = dz.d @@ -309,7 +309,7 @@ New expression 3 of 3: ---- # No joins should be reordered besides commutation. -memo join-limit=0 expect-not=ReorderJoins +memo set=reorder_joins_limit=0 expect-not=ReorderJoins SELECT * FROM bx, cy, abc WHERE a = 1 AND abc.b = bx.b AND abc.c = cy.c ---- memo (optimized, ~22KB, required=[presentation: b:1,x:2,c:5,y:6,a:9,b:10,c:11,d:12]) @@ -357,7 +357,7 @@ memo (optimized, ~22KB, required=[presentation: b:1,x:2,c:5,y:6,a:9,b:10,c:11,d: ├── G18: (variable a) └── G19: (const 1) -memo join-limit=2 +memo set=reorder_joins_limit=2 SELECT * FROM bx, cy, abc WHERE a = 1 AND abc.b = bx.b AND abc.c = cy.c ---- memo (optimized, ~33KB, required=[presentation: b:1,x:2,c:5,y:6,a:9,b:10,c:11,d:12]) @@ -409,7 +409,7 @@ memo (optimized, ~33KB, required=[presentation: b:1,x:2,c:5,y:6,a:9,b:10,c:11,d: ├── G19: (variable a) └── G20: (const 1) -opt join-limit=3 expect=ReorderJoins +opt set=reorder_joins_limit=3 expect=ReorderJoins SELECT * FROM bx, cy, dz, abc WHERE a = 1 ---- inner-join (cross) @@ -447,7 +447,7 @@ inner-join (cross) │ └── fd: (1)-->(2) └── filters (true) -opt join-limit=2 format=show-all +opt set=reorder_joins_limit=2 format=show-all SELECT * FROM abc, bx, cy, dz WHERE a = 1 ---- inner-join (cross) @@ -518,7 +518,7 @@ inner-join (cross) # Note the difference in memo size for with and without reorder-joins, for only four tables. # TODO(justin): Find a way to reduce this. -memo join-limit=0 +memo set=reorder_joins_limit=0 SELECT * FROM bx, cy, dz, abc WHERE x = y AND y = z AND z = a ---- memo (optimized, ~29KB, required=[presentation: b:1,x:2,c:5,y:6,d:9,z:10,a:13,b:14,c:15,d:16]) @@ -584,7 +584,7 @@ memo (optimized, ~29KB, required=[presentation: b:1,x:2,c:5,y:6,d:9,z:10,a:13,b: # are connected, which allows every join order to be added to the memo. # TODO(drewk): implement branch pruning and/or a max operator limit for the # memo. -memo join-limit=3 +memo set=reorder_joins_limit=3 SELECT * FROM bx, cy, dz, abc WHERE x = y AND y = z AND z = a ---- memo (optimized, ~62KB, required=[presentation: b:1,x:2,c:5,y:6,d:9,z:10,a:13,b:14,c:15,d:16]) @@ -752,7 +752,7 @@ exec-ddl CREATE TABLE a (id INT8 PRIMARY KEY) ---- -opt join-limit=3 +opt set=reorder_joins_limit=3 SELECT 1 FROM @@ -1965,7 +1965,7 @@ full-join (hash) └── y = z # Iteratively reorder subtrees of up to size 2. -reorderjoins join-limit=2 format=hide-all +reorderjoins set=reorder_joins_limit=2 format=hide-all SELECT * FROM abc AS a1 INNER JOIN abc AS a2 ON a1.a = a2.a LEFT JOIN abc AS a3 ON a2.b = a3.b