Skip to content

Commit 90765a4

Browse files
committed
logictest: extend a few EXPLAIN tests a bit
This commit adjusts a few existing EXPLAIN tests to use VERBOSE as well as adds another RBR setup with CASCADE FKs. These will be used to highlight the parallelization change in the multi-key lookup joins in the following commit. Release note: None
1 parent 1219537 commit 90765a4

File tree

4 files changed

+237
-14
lines changed

4 files changed

+237
-14
lines changed
Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
# LogicTest: multiregion-9node-3region-3azs
2+
3+
# Set the closed timestamp interval to be short to shorten the amount of time
4+
# we need to wait for the system config to propagate.
5+
statement ok
6+
SET CLUSTER SETTING kv.closed_timestamp.side_transport_interval = '10ms';
7+
8+
statement ok
9+
SET CLUSTER SETTING kv.closed_timestamp.target_duration = '10ms';
10+
11+
statement ok
12+
SET CLUSTER SETTING kv.rangefeed.closed_timestamp_refresh_interval = '10ms';
13+
14+
statement ok
15+
CREATE DATABASE multi_region_test_db PRIMARY REGION "ca-central-1" REGIONS "ap-southeast-2", "us-east-1" SURVIVE REGION FAILURE;
16+
17+
statement ok
18+
USE multi_region_test_db
19+
20+
statement ok
21+
CREATE TABLE great_grandparent (
22+
i INT NOT NULL PRIMARY KEY,
23+
gg INT NOT NULL,
24+
UNIQUE INDEX (gg),
25+
FAMILY (i, gg)
26+
) LOCALITY REGIONAL BY ROW;
27+
28+
statement ok
29+
CREATE TABLE grandparent (
30+
g INT NOT NULL PRIMARY KEY,
31+
gg INT NOT NULL REFERENCES great_grandparent (gg) ON DELETE CASCADE ON UPDATE CASCADE,
32+
INDEX (gg),
33+
FAMILY (g, gg)
34+
) LOCALITY REGIONAL BY ROW;
35+
36+
statement ok
37+
CREATE TABLE parent (
38+
p INT NOT NULL PRIMARY KEY,
39+
g INT NOT NULL REFERENCES grandparent (g) ON DELETE CASCADE ON UPDATE CASCADE,
40+
INDEX (g),
41+
FAMILY (p, g)
42+
) LOCALITY REGIONAL BY ROW;
43+
44+
statement ok
45+
CREATE TABLE child (
46+
c INT NOT NULL PRIMARY KEY,
47+
p INT NOT NULL REFERENCES parent (p) ON DELETE CASCADE ON UPDATE CASCADE,
48+
INDEX (p),
49+
FAMILY (c, p)
50+
) LOCALITY REGIONAL BY ROW;
51+
52+
statement ok
53+
INSERT INTO great_grandparent (i, gg, crdb_region) VALUES (1, 1, 'us-east-1'), (2, 2, 'us-east-1'), (3, 3, 'us-east-1');
54+
INSERT INTO grandparent (g, gg, crdb_region) VALUES (10, 1, 'us-east-1'), (20, 2, 'us-east-1'), (30, 3, 'us-east-1');
55+
INSERT INTO parent (p, g, crdb_region) VALUES (100, 10, 'us-east-1'), (200, 20, 'us-east-1'), (300, 30, 'us-east-1');
56+
INSERT INTO child (c, p, crdb_region) VALUES (1000, 100, 'us-east-1'), (2000, 200, 'us-east-1'), (3000, 300, 'us-east-1');
57+
58+
statement ok
59+
ANALYZE great_grandparent;
60+
61+
statement ok
62+
ANALYZE grandparent;
63+
64+
statement ok
65+
ANALYZE parent;
66+
67+
statement ok
68+
ANALYZE child;
69+
70+
query T
71+
EXPLAIN (VERBOSE) DELETE FROM great_grandparent WHERE i = 1;
72+
----
73+
distribution: local
74+
vectorized: true
75+
·
76+
• root
77+
│ columns: ()
78+
79+
├── • delete
80+
│ │ columns: ()
81+
│ │ estimated row count: 0 (missing stats)
82+
│ │ from: great_grandparent
83+
│ │
84+
│ └── • buffer
85+
│ │ columns: (i, gg, crdb_region)
86+
│ │ label: buffer 1
87+
│ │
88+
│ └── • union all
89+
│ │ columns: (i, gg, crdb_region)
90+
│ │ estimated row count: 1
91+
│ │ limit: 1
92+
│ │
93+
│ ├── • scan
94+
│ │ columns: (i, gg, crdb_region)
95+
│ │ estimated row count: 0 (<0.01% of the table; stats collected <hidden> ago)
96+
│ │ table: great_grandparent@great_grandparent_pkey
97+
│ │ spans: /"@"/1/0
98+
│ │
99+
│ └── • scan
100+
│ columns: (i, gg, crdb_region)
101+
│ estimated row count: 1 (33% of the table; stats collected <hidden> ago)
102+
│ table: great_grandparent@great_grandparent_pkey
103+
│ spans: /"\x80"/1/0 /"\xc0"/1/0
104+
│ parallel
105+
106+
└── • fk-cascade
107+
│ fk: grandparent_gg_fkey
108+
109+
└── • root
110+
│ columns: ()
111+
112+
├── • delete
113+
│ │ columns: ()
114+
│ │ estimated row count: 0 (missing stats)
115+
│ │ from: grandparent
116+
│ │
117+
│ └── • buffer
118+
│ │ columns: (g, gg, crdb_region)
119+
│ │ label: buffer 1
120+
│ │
121+
│ └── • project
122+
│ │ columns: (g, gg, crdb_region)
123+
│ │
124+
│ └── • lookup join (inner)
125+
│ │ columns: (gg, g, gg, crdb_region)
126+
│ │ estimated row count: 3
127+
│ │ table: grandparent@grandparent_gg_idx
128+
│ │ lookup condition: (crdb_region IN ('ap-southeast-2', 'ca-central-1', 'us-east-1')) AND (gg = gg)
129+
│ │
130+
│ └── • distinct
131+
│ │ columns: (gg)
132+
│ │ estimated row count: 10
133+
│ │ distinct on: gg
134+
│ │
135+
│ └── • project
136+
│ │ columns: (gg)
137+
│ │
138+
│ └── • scan buffer
139+
│ columns: (i, gg, crdb_region)
140+
│ estimated row count: 100
141+
│ label: buffer 1000000
142+
143+
└── • fk-cascade
144+
│ fk: parent_g_fkey
145+
146+
└── • root
147+
│ columns: ()
148+
149+
├── • delete
150+
│ │ columns: ()
151+
│ │ estimated row count: 0 (missing stats)
152+
│ │ from: parent
153+
│ │
154+
│ └── • buffer
155+
│ │ columns: (p, g, crdb_region)
156+
│ │ label: buffer 1
157+
│ │
158+
│ └── • project
159+
│ │ columns: (p, g, crdb_region)
160+
│ │
161+
│ └── • lookup join (inner)
162+
│ │ columns: (g, p, g, crdb_region)
163+
│ │ estimated row count: 3
164+
│ │ table: parent@parent_g_idx
165+
│ │ lookup condition: (crdb_region IN ('ap-southeast-2', 'ca-central-1', 'us-east-1')) AND (g = g)
166+
│ │
167+
│ └── • distinct
168+
│ │ columns: (g)
169+
│ │ estimated row count: 10
170+
│ │ distinct on: g
171+
│ │
172+
│ └── • project
173+
│ │ columns: (g)
174+
│ │
175+
│ └── • scan buffer
176+
│ columns: (g, gg, crdb_region)
177+
│ estimated row count: 100
178+
│ label: buffer 1000000
179+
180+
└── • fk-cascade
181+
│ fk: child_p_fkey
182+
183+
└── • delete
184+
│ columns: ()
185+
│ estimated row count: 0 (missing stats)
186+
│ from: child
187+
188+
└── • project
189+
│ columns: (c, p, crdb_region)
190+
191+
└── • lookup join (inner)
192+
│ columns: (p, c, p, crdb_region)
193+
│ estimated row count: 3
194+
│ table: child@child_p_idx
195+
│ lookup condition: (crdb_region IN ('ap-southeast-2', 'ca-central-1', 'us-east-1')) AND (p = p)
196+
197+
└── • distinct
198+
│ columns: (p)
199+
│ estimated row count: 10
200+
│ distinct on: p
201+
202+
└── • project
203+
│ columns: (p)
204+
205+
└── • scan buffer
206+
columns: (p, g, crdb_region)
207+
estimated row count: 100
208+
label: buffer 1000000

pkg/ccl/logictestccl/testdata/logic_test/regional_by_row_query_behavior

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3582,7 +3582,7 @@ ALTER TABLE xyz INJECT STATISTICS '[
35823582

35833583
# Regression test for #105942.
35843584
query T retry
3585-
EXPLAIN SELECT
3585+
EXPLAIN (VERBOSE) SELECT
35863586
xyz.str,
35873587
abc.id,
35883588
abc.id1,
@@ -3603,20 +3603,28 @@ WHERE
36033603
distribution: local
36043604
vectorized: true
36053605
·
3606-
• lookup join
3607-
│ estimated row count: 1
3608-
│ table: xyz@xyz_id2_str_abc_id_idx
3609-
│ equality: (crdb_region, id2) = (crdb_region, id2)
3610-
│ pred: ((abc_id = id) AND (id2 = '68088706-02c6-47d1-b993-a421cd761f2b')) AND (crdb_region = 'ap-southeast-2')
3606+
• project
3607+
│ columns: (str, id, id1, id2, created_at, updated_at)
36113608
3612-
└── • index join
3613-
│ estimated row count: 0
3614-
│ table: abc@abc_pkey
3609+
└── • lookup join (inner)
3610+
│ columns: (id, id1, created_at, updated_at, id2, crdb_region, str, abc_id, id2, crdb_region)
3611+
│ estimated row count: 1
3612+
│ table: xyz@xyz_id2_str_abc_id_idx
3613+
│ equality: (crdb_region, id2) = (crdb_region, id2)
3614+
│ pred: ((abc_id = id) AND (id2 = '68088706-02c6-47d1-b993-a421cd761f2b')) AND (crdb_region = 'ap-southeast-2')
36153615
3616-
└── • scan
3617-
estimated row count: 0 (0.37% of the table; stats collected <hidden> ago)
3618-
table: abc@abc_id1_id2_idx
3619-
spans: [/'ap-southeast-2'/'6da4f356-e526-4b78-b9f9-bbb1a7fc12d6'/'68088706-02c6-47d1-b993-a421cd761f2b' - /'ap-southeast-2'/'6da4f356-e526-4b78-b9f9-bbb1a7fc12d6'/'68088706-02c6-47d1-b993-a421cd761f2b']
3616+
└── • index join
3617+
│ columns: (id, id1, created_at, updated_at, id2, crdb_region)
3618+
│ estimated row count: 0
3619+
│ table: abc@abc_pkey
3620+
│ key columns: crdb_region, id
3621+
│ parallel
3622+
3623+
└── • scan
3624+
columns: (id, id1, id2, crdb_region)
3625+
estimated row count: 0 (0.37% of the table; stats collected <hidden> ago)
3626+
table: abc@abc_id1_id2_idx
3627+
spans: /"@"/"m\xa4\xf3V\xe5&Kx\xb9\xf9\xbb\xb1\xa7\xfc\x12\xd6"/"h\b\x87\x06\x02\xc6Gѹ\x93\xa4!\xcdv\x1f+"-/"@"/"m\xa4\xf3V\xe5&Kx\xb9\xf9\xbb\xb1\xa7\xfc\x12\xd6"/"h\b\x87\x06\x02\xc6Gѹ\x93\xa4!\xcdv\x1f+"/PrefixEnd
36203628

36213629
# The following should use a string of 4 lookup/index joins with a cost under 200.
36223630
query T retry

pkg/ccl/logictestccl/tests/multiregion-9node-3region-3azs/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ go_test(
99
"//pkg/ccl/logictestccl:testdata", # keep
1010
],
1111
exec_properties = {"test.Pool": "large"},
12-
shard_count = 29,
12+
shard_count = 30,
1313
tags = ["cpu:4"],
1414
deps = [
1515
"//pkg/base",

pkg/ccl/logictestccl/tests/multiregion-9node-3region-3azs/generated_test.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)