Skip to content

Commit

Permalink
sql: default index recommendations to be off for logic tests
Browse files Browse the repository at this point in the history
This commit configures index recommendations to be off for logic tests.
This is to avoid flaky tests, as the index recommendation output can
vary depending on the best plan chosen by the optimizer.

Fixes: #74069.

Release note: None
  • Loading branch information
Neha George committed Dec 21, 2021
1 parent d8a4967 commit da3be4e
Show file tree
Hide file tree
Showing 43 changed files with 9 additions and 1,555 deletions.
2 changes: 1 addition & 1 deletion pkg/ccl/logictestccl/testdata/logic_test/as_of
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ SELECT * FROM t AS OF SYSTEM TIME with_max_staleness('1ms') WHERE j = 2
query T
EXPLAIN (OPT, MEMO) SELECT * FROM t AS OF SYSTEM TIME with_max_staleness('1ms') WHERE j = 2 AND i = 1
----
memo (optimized, ~5KB, required=[presentation: info:6])
memo (optimized, ~8KB, required=[presentation: info:6])
├── G1: (explain G2 [presentation: i:1,j:2,k:3])
│ └── [presentation: info:6]
│ ├── best: (explain G2="[presentation: i:1,j:2,k:3]" [presentation: i:1,j:2,k:3])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ select
│ ├── [/3/3/1 - /3/3/9]
│ └── [/3/4/1 - ]
└── filters
├── (c > 0) AND (c < 10)
└── (c % 2) = 1
├── (c % 2) = 1
└── (c > 0) AND (c < 10)

# Perhaps an unintuitive example. The partition constraints don't really help
# constrain the index. None of the spans created by the partitioning are constrained
Expand Down
22 changes: 0 additions & 22 deletions pkg/ccl/logictestccl/testdata/logic_test/partitioning_implicit
Original file line number Diff line number Diff line change
Expand Up @@ -298,12 +298,6 @@ vectorized: true
└── • scan buffer
label: buffer 1
·
index recommendations: 2
1. type: index creation
SQL command: CREATE INDEX ON t (pk);
2. type: index creation
SQL command: CREATE INDEX ON t (c);

statement ok
INSERT INTO fk_using_implicit_columns_against_t VALUES (1, 1, 4)
Expand Down Expand Up @@ -805,14 +799,6 @@ vectorized: true
└── • scan buffer
label: buffer 1
·
index recommendations: 3
1. type: index creation
SQL command: CREATE INDEX ON t (pk);
2. type: index creation
SQL command: CREATE INDEX ON t (b);
3. type: index creation
SQL command: CREATE INDEX ON t (c, d);

statement ok
INSERT INTO t VALUES (1, 1, 1, 1, 1, 1, 1), (2, 2, 2, 2, 2, 2, 2)
Expand Down Expand Up @@ -898,14 +884,6 @@ vectorized: true
└── • scan buffer
label: buffer 1
·
index recommendations: 3
1. type: index creation
SQL command: CREATE INDEX ON t (pk) STORING (pk2, a, b, c, d);
2. type: index creation
SQL command: CREATE INDEX ON t (b);
3. type: index creation
SQL command: CREATE INDEX ON t (c, d);

# One row already exists, one row is new.
statement ok
Expand Down
6 changes: 6 additions & 0 deletions pkg/sql/logictest/logic.go
Original file line number Diff line number Diff line change
Expand Up @@ -1364,6 +1364,12 @@ func (t *logicTest) setUser(user string, nodeIdxOverride int) func() {
if _, err := db.Exec("SET extra_float_digits = 0"); err != nil {
t.Fatal(err)
}
// The default setting for index_recommendations_enabled is true. We do not
// want to display index recommendations in logic tests, so we disable them
// here.
if _, err := db.Exec("SET index_recommendations_enabled = false"); err != nil {
t.Fatal(err)
}
t.clients[user] = db
t.db = db
t.user = user
Expand Down
52 changes: 0 additions & 52 deletions pkg/sql/opt/exec/execbuilder/testdata/aggregate
Original file line number Diff line number Diff line change
Expand Up @@ -1191,10 +1191,6 @@ vectorized: true
estimated row count: 1,000 (missing stats)
table: kv@kv_pkey
spans: FULL SCAN
·
index recommendations: 1
1. type: index creation
SQL command: CREATE INDEX ON kv (v);

query T
EXPLAIN (TYPES) SELECT v, count(*) FROM kv GROUP BY v ORDER BY count(*)
Expand All @@ -1219,10 +1215,6 @@ vectorized: true
estimated row count: 1,000 (missing stats)
table: kv@kv_pkey
spans: FULL SCAN
·
index recommendations: 1
1. type: index creation
SQL command: CREATE INDEX ON kv (v);

query T
EXPLAIN (TYPES) SELECT v, count(NULL) FROM kv GROUP BY v ORDER BY count(1)
Expand Down Expand Up @@ -1257,10 +1249,6 @@ vectorized: true
estimated row count: 1,000 (missing stats)
table: kv@kv_pkey
spans: FULL SCAN
·
index recommendations: 1
1. type: index creation
SQL command: CREATE INDEX ON kv (v);

# Check that filters propagate through no-op aggregation.
query T
Expand Down Expand Up @@ -1291,10 +1279,6 @@ vectorized: true
estimated row count: 1,000 (missing stats)
table: kv@kv_pkey
spans: FULL SCAN
·
index recommendations: 1
1. type: index creation
SQL command: CREATE INDEX ON kv (v);

# Verify that FILTER works.

Expand Down Expand Up @@ -1335,10 +1319,6 @@ vectorized: true
estimated row count: 1,000 (missing stats)
table: filter_test@filter_test_pkey
spans: FULL SCAN
·
index recommendations: 1
1. type: index creation
SQL command: CREATE INDEX ON filter_test (v) STORING (k);

query T
EXPLAIN (VERBOSE) SELECT count(*) FILTER (WHERE k > 5) FROM filter_test GROUP BY v
Expand Down Expand Up @@ -1368,10 +1348,6 @@ vectorized: true
estimated row count: 1,000 (missing stats)
table: filter_test@filter_test_pkey
spans: FULL SCAN
·
index recommendations: 1
1. type: index creation
SQL command: CREATE INDEX ON filter_test (v) STORING (k);

# Tests with * inside GROUP BY.
query T
Expand Down Expand Up @@ -1828,10 +1804,6 @@ vectorized: true
estimated row count: 1,000 (missing stats)
table: kv@kv_pkey
spans: FULL SCAN
·
index recommendations: 1
1. type: index creation
SQL command: CREATE INDEX ON kv (v);

query T
EXPLAIN (VERBOSE) SELECT k FROM kv ORDER BY s
Expand All @@ -1853,10 +1825,6 @@ vectorized: true
estimated row count: 1,000 (missing stats)
table: kv@kv_pkey
spans: FULL SCAN
·
index recommendations: 1
1. type: index creation
SQL command: CREATE INDEX ON kv (s);

query T
EXPLAIN (VERBOSE) SELECT concat_agg(s) FROM (SELECT s FROM kv ORDER BY k)
Expand Down Expand Up @@ -1898,10 +1866,6 @@ vectorized: true
estimated row count: 1,000 (missing stats)
table: kv@kv_pkey
spans: FULL SCAN
·
index recommendations: 1
1. type: index creation
SQL command: CREATE INDEX ON kv (s);

query T
EXPLAIN (VERBOSE) SELECT string_agg(s, ',') FROM (SELECT s FROM kv ORDER BY k)
Expand Down Expand Up @@ -2055,10 +2019,6 @@ vectorized: true
estimated row count: 1,000 (missing stats)
table: string_agg_test@string_agg_test_pkey
spans: FULL SCAN
·
index recommendations: 1
1. type: index creation
SQL command: CREATE INDEX ON string_agg_test (company_id) STORING (employee);

query T
EXPLAIN (VERBOSE)
Expand Down Expand Up @@ -2098,10 +2058,6 @@ vectorized: true
estimated row count: 1,000 (missing stats)
table: string_agg_test@string_agg_test_pkey
spans: FULL SCAN
·
index recommendations: 1
1. type: index creation
SQL command: CREATE INDEX ON string_agg_test (company_id) STORING (employee);

query T
EXPLAIN (VERBOSE)
Expand Down Expand Up @@ -2141,10 +2097,6 @@ vectorized: true
estimated row count: 1,000 (missing stats)
table: string_agg_test@string_agg_test_pkey
spans: FULL SCAN
·
index recommendations: 1
1. type: index creation
SQL command: CREATE INDEX ON string_agg_test (company_id) STORING (employee);

query T
EXPLAIN (VERBOSE)
Expand Down Expand Up @@ -2184,7 +2136,3 @@ vectorized: true
estimated row count: 1,000 (missing stats)
table: string_agg_test@string_agg_test_pkey
spans: FULL SCAN
·
index recommendations: 1
1. type: index creation
SQL command: CREATE INDEX ON string_agg_test (company_id) STORING (employee);
4 changes: 0 additions & 4 deletions pkg/sql/opt/exec/execbuilder/testdata/array
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,3 @@ vectorized: true
missing stats
table: t@t_pkey
spans: FULL SCAN
·
index recommendations: 1
1. type: index creation
SQL command: CREATE INDEX ON t (x) STORING (y, z);
16 changes: 0 additions & 16 deletions pkg/sql/opt/exec/execbuilder/testdata/delete
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ vectorized: true
missing stats
table: unindexed@unindexed_pkey
spans: FULL SCAN
·
index recommendations: 1
1. type: index creation
SQL command: CREATE INDEX ON unindexed (v);

# Check DELETE with LIMIT clause (MySQL extension)
query T
Expand All @@ -113,10 +109,6 @@ vectorized: true
missing stats
table: unindexed@unindexed_pkey
spans: FULL SCAN
·
index recommendations: 1
1. type: index creation
SQL command: CREATE INDEX ON unindexed (v);

# Check fast DELETE.
query T
Expand Down Expand Up @@ -296,10 +288,6 @@ vectorized: true
estimated row count: 1,000 (missing stats)
table: xyz@xyz_pkey
spans: FULL SCAN
·
index recommendations: 1
1. type: index replacement
SQL commands: CREATE INDEX ON xyz (y) STORING (z); DROP INDEX xyz@xyz_y_idx;

# With the hint, we use a constrained scan.
query T
Expand Down Expand Up @@ -329,7 +317,3 @@ vectorized: true
estimated row count: 990 (missing stats)
table: xyz@xyz_y_idx
spans: /1-/1000 /2001-/3000
·
index recommendations: 1
1. type: index replacement
SQL commands: CREATE INDEX ON xyz (y) STORING (z); DROP INDEX xyz@xyz_y_idx;
10 changes: 0 additions & 10 deletions pkg/sql/opt/exec/execbuilder/testdata/dist_union
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ vectorized: true
missing stats
table: uniontest@uniontest_pkey
spans: FULL SCAN
·
index recommendations: 2
1. type: index creation
SQL command: CREATE INDEX ON uniontest (v);
2. type: index creation
SQL command: CREATE INDEX ON uniontest (k);

query T
EXPLAIN SELECT v FROM uniontest UNION ALL SELECT k FROM uniontest
Expand Down Expand Up @@ -99,10 +93,6 @@ vectorized: true
estimated row count: 1,000 (missing stats)
table: abc@abc_pkey
spans: FULL SCAN
·
index recommendations: 1
1. type: index creation
SQL command: CREATE INDEX ON abc (a) STORING (b);

# Regression test for #32723.
query T
Expand Down
16 changes: 0 additions & 16 deletions pkg/sql/opt/exec/execbuilder/testdata/distinct
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ vectorized: true
missing stats
table: xyz@foo
spans: FULL SCAN
·
index recommendations: 1
1. type: index creation
SQL command: CREATE INDEX ON xyz (y) STORING (z);

query T
EXPLAIN SELECT DISTINCT y, z FROM xyz ORDER BY y, z
Expand All @@ -77,10 +73,6 @@ vectorized: true
missing stats
table: xyz@foo
spans: FULL SCAN
·
index recommendations: 1
1. type: index creation
SQL command: CREATE INDEX ON xyz (y, z);

query T
EXPLAIN SELECT DISTINCT y + z AS r FROM xyz ORDER BY y + z
Expand Down Expand Up @@ -133,10 +125,6 @@ vectorized: true
missing stats
table: xyz@xyz_pkey
spans: FULL SCAN
·
index recommendations: 1
1. type: index creation
SQL command: CREATE INDEX ON xyz (y);

query T
EXPLAIN (VERBOSE) SELECT DISTINCT x FROM xyz
Expand Down Expand Up @@ -191,10 +179,6 @@ vectorized: true
estimated row count: 1,000 (missing stats)
table: xyz@foo
spans: FULL SCAN
·
index recommendations: 1
1. type: index creation
SQL command: CREATE INDEX ON xyz (y) STORING (z);

statement ok
CREATE TABLE abcd (
Expand Down
Loading

0 comments on commit da3be4e

Please sign in to comment.