You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c189bd9
Browse filesBrowse the repository at this point in the historyBrowse files
-- Checks that `parallel_replicas_for_queries_with_multiple_tables` reaches every place that plans a
2
-
-- part of a multi-table query, by looking for `ReadFromRemoteParallelReplicas` in the query plan.
2
+
-- part of a multi-table query, by looking for the read from the other replicas in the query plan:
3
+
-- `ReadFromRemoteParallelReplicas`, or `ReadFromParallelReplicas` with `parallel_replicas_plan_based`.
4
+
-- Each probe prints whether there is one, not how many: the two implementations split the same query
5
+
-- into a different number of reads.
3
6
-- The probes that cannot be seen in `EXPLAIN` live in `05137_pr_disable_for_multiple_tables_execution`.
4
7
5
8
droptable if exists X;
6
9
droptable if exists Y;
10
+
droptable if exists Z;
11
+
droptable if exists W;
7
12
8
13
createtableX (id Int32, x_a String, x_b Nullable(Int32)) engine MergeTree order by id settings index_granularity=1;
9
14
createtableY (id Int32, y_a String, y_b Nullable(String)) engine MergeTree order by id settings index_granularity=1;
15
+
-- Copies of `X` for the `UNION` probes: plan-based parallel replicas leave local a union whose branches read
16
+
-- the same table, so each branch reads its own.
17
+
createtableZas X;
18
+
createtableWas X;
10
19
11
20
insert into X (id, x_a, x_b) selectnumber, toString(number), -numberfrom numbers(100);
12
21
insert into X (id, x_a, x_b) values (1, 'l1', 1), (2, 'l2', 2), (2, 'l3', 3), (3, 'l4', 4);
13
22
insert into X (id, x_a) values (4, 'l5'), (4, 'l6'), (5, 'l7'), (8, 'l8'), (9, 'l9');
14
23
insert into X (id, x_a, x_b) selectnumber, toString(number), toString(-number) from numbers(100);
15
24
insert into Y (id, y_a) values (1, 'r1'), (1, 'r2'), (2, 'r3'), (3, 'r4'), (3, 'r5');
16
25
insert into Y (id, y_a, y_b) values (4, 'r6', 'nr6'), (6, 'r7', 'nr7'), (7, 'r8', 'nr8'), (9, 'r9', 'nr9');
26
+
insert into Z select*from X;
27
+
insert into W select*from X;
17
28
18
29
set enable_parallel_replicas =1, max_parallel_replicas =3, cluster_for_parallel_replicas ='test_cluster_one_shard_three_replicas_localhost';
19
30
@@ -27,61 +38,63 @@ set automatic_parallel_replicas_mode = 0, parallel_replicas_local_plan = 1, seri
27
38
set parallel_replicas_for_non_replicated_merge_tree =1;
28
39
29
40
set parallel_replicas_for_queries_with_multiple_tables=1;
30
-
selectcount() from (explain select X.*, Y.*from X inner join Y onX.id=Y.id) where explain ilike '%ReadFromRemoteParallelReplicas%';
41
+
selectcount() >0from (explain select X.*, Y.*from X inner join Y onX.id=Y.id) where explain ilike '%ReadFromRemoteParallelReplicas%'or explain ilike '%ReadFromParallelReplicas%';
31
42
set parallel_replicas_for_queries_with_multiple_tables=0;
32
-
selectcount() from (explain select X.*, Y.*from X inner join Y onX.id=Y.id) where explain ilike '%ReadFromRemoteParallelReplicas%';
43
+
selectcount() >0from (explain select X.*, Y.*from X inner join Y onX.id=Y.id) where explain ilike '%ReadFromRemoteParallelReplicas%'or explain ilike '%ReadFromParallelReplicas%';
33
44
34
45
set parallel_replicas_for_queries_with_multiple_tables=1;
35
-
selectcount() from (explain select*from (select X.*, Y.*from X inner join Y onX.id=Y.id)) where explain ilike '%ReadFromRemoteParallelReplicas%';
46
+
selectcount() >0from (explain select*from (select X.*, Y.*from X inner join Y onX.id=Y.id)) where explain ilike '%ReadFromRemoteParallelReplicas%'or explain ilike '%ReadFromParallelReplicas%';
36
47
set parallel_replicas_for_queries_with_multiple_tables=0;
37
-
selectcount() from (explain select*from (select X.*, Y.*from X inner join Y onX.id=Y.id)) where explain ilike '%ReadFromRemoteParallelReplicas%';
48
+
selectcount() >0from (explain select*from (select X.*, Y.*from X inner join Y onX.id=Y.id)) where explain ilike '%ReadFromRemoteParallelReplicas%'or explain ilike '%ReadFromParallelReplicas%';
38
49
39
50
set parallel_replicas_for_queries_with_multiple_tables=1;
40
-
selectcount() from (explain select*from (select*from X) as s inner join Y as j ons.id=j.id) where explain ilike '%ReadFromRemoteParallelReplicas%';
51
+
selectcount() >0from (explain select*from (select*from X) as s inner join Y as j ons.id=j.id) where explain ilike '%ReadFromRemoteParallelReplicas%'or explain ilike '%ReadFromParallelReplicas%';
41
52
set parallel_replicas_for_queries_with_multiple_tables=0;
42
-
selectcount() from (explain select*from (select*from X) as s inner join Y as j ons.id=j.id) where explain ilike '%ReadFromRemoteParallelReplicas%';
53
+
selectcount() >0from (explain select*from (select*from X) as s inner join Y as j ons.id=j.id) where explain ilike '%ReadFromRemoteParallelReplicas%'or explain ilike '%ReadFromParallelReplicas%';
43
54
44
55
set parallel_replicas_for_queries_with_multiple_tables=1;
45
-
selectcount() from (explain select*from X as s inner join (select*from Y) as j ons.id=j.id) where explain ilike '%ReadFromRemoteParallelReplicas%';
56
+
selectcount() >0from (explain select*from X as s inner join (select*from Y) as j ons.id=j.id) where explain ilike '%ReadFromRemoteParallelReplicas%'or explain ilike '%ReadFromParallelReplicas%';
46
57
set parallel_replicas_for_queries_with_multiple_tables=0;
47
-
selectcount() from (explain select*from X as s inner join (select*from Y) as j ons.id=j.id) where explain ilike '%ReadFromRemoteParallelReplicas%';
58
+
selectcount() >0from (explain select*from X as s inner join (select*from Y) as j ons.id=j.id) where explain ilike '%ReadFromRemoteParallelReplicas%'or explain ilike '%ReadFromParallelReplicas%';
48
59
49
60
set parallel_replicas_for_queries_with_multiple_tables=1;
50
-
selectcount() from (explain select*from (select*from X) as s inner join (select*from Y) as j ons.id=j.id) where explain ilike '%ReadFromRemoteParallelReplicas%';
61
+
selectcount() >0from (explain select*from (select*from X) as s inner join (select*from Y) as j ons.id=j.id) where explain ilike '%ReadFromRemoteParallelReplicas%'or explain ilike '%ReadFromParallelReplicas%';
51
62
set parallel_replicas_for_queries_with_multiple_tables=0;
52
-
selectcount() from (explain select*from (select*from X) as s inner join (select*from Y) as j ons.id=j.id) where explain ilike '%ReadFromRemoteParallelReplicas%';
63
+
selectcount() >0from (explain select*from (select*from X) as s inner join (select*from Y) as j ons.id=j.id) where explain ilike '%ReadFromRemoteParallelReplicas%'or explain ilike '%ReadFromParallelReplicas%';
53
64
54
65
set parallel_replicas_for_queries_with_multiple_tables=1;
55
-
selectcount() from (explain select*from (select*from X) as s inner join (select*from Y order by id) as j ons.id=j.id) where explain ilike '%ReadFromRemoteParallelReplicas%';
66
+
selectcount() >0from (explain select*from (select*from X) as s inner join (select*from Y order by id) as j ons.id=j.id) where explain ilike '%ReadFromRemoteParallelReplicas%'or explain ilike '%ReadFromParallelReplicas%';
56
67
set parallel_replicas_for_queries_with_multiple_tables=0;
57
-
selectcount() from (explain select*from (select*from X) as s inner join (select*from Y order by id) as j ons.id=j.id) where explain ilike '%ReadFromRemoteParallelReplicas%';
68
+
selectcount() >0from (explain select*from (select*from X) as s inner join (select*from Y order by id) as j ons.id=j.id) where explain ilike '%ReadFromRemoteParallelReplicas%'or explain ilike '%ReadFromParallelReplicas%';
58
69
59
70
set parallel_replicas_for_queries_with_multiple_tables=1;
60
-
selectcount() from (explain select*from (select*from X order by id) as s inner join (select*from Y) as j ons.id=j.id) where explain ilike '%ReadFromRemoteParallelReplicas%';
71
+
selectcount() >0from (explain select*from (select*from X order by id) as s inner join (select*from Y) as j ons.id=j.id) where explain ilike '%ReadFromRemoteParallelReplicas%'or explain ilike '%ReadFromParallelReplicas%';
61
72
set parallel_replicas_for_queries_with_multiple_tables=0;
62
-
selectcount() from (explain select*from (select*from X order by id) as s inner join (select*from Y) as j ons.id=j.id) where explain ilike '%ReadFromRemoteParallelReplicas%';
73
+
selectcount() >0from (explain select*from (select*from X order by id) as s inner join (select*from Y) as j ons.id=j.id) where explain ilike '%ReadFromRemoteParallelReplicas%'or explain ilike '%ReadFromParallelReplicas%';
63
74
64
75
-- ARRAY JOIN over a single table is not a multi-table query, so parallel replicas must stay enabled
65
76
-- regardless of the setting. The check must count actual joins, not the table expressions stack size,
66
77
-- which also includes the ARRAY_JOIN node.
67
78
set parallel_replicas_for_queries_with_multiple_tables=1;
68
-
selectcount() from (explain select id, n from X array join [1, 2] as n) where explain ilike '%ReadFromRemoteParallelReplicas%';
79
+
selectcount() >0from (explain select id, n from X array join [1, 2] as n) where explain ilike '%ReadFromRemoteParallelReplicas%'or explain ilike '%ReadFromParallelReplicas%';
69
80
set parallel_replicas_for_queries_with_multiple_tables=0;
70
-
selectcount() from (explain select id, n from X array join [1, 2] as n) where explain ilike '%ReadFromRemoteParallelReplicas%';
81
+
selectcount() >0from (explain select id, n from X array join [1, 2] as n) where explain ilike '%ReadFromRemoteParallelReplicas%'or explain ilike '%ReadFromParallelReplicas%';
71
82
72
83
-- A `UNION` table expression nested under a `JOIN` is planned branch by branch, and every branch is
73
84
-- planned by an independent `Planner` built from the branch's own context, so disabling the setting
74
85
-- must reach the branch contexts as well, not only the `UnionNode` context.
75
86
set parallel_replicas_for_queries_with_multiple_tables=1;
76
-
selectcount() from (explain select*from (select id from X union allselect id fromX) as u inner join Y as j onu.id=j.id) where explain ilike '%ReadFromRemoteParallelReplicas%';
87
+
selectcount() >0from (explain select*from (select id from X union allselect id fromZ) as u inner join Y as j onu.id=j.id) where explain ilike '%ReadFromRemoteParallelReplicas%'or explain ilike '%ReadFromParallelReplicas%';
77
88
set parallel_replicas_for_queries_with_multiple_tables=0;
78
-
selectcount() from (explain select*from (select id from X union allselect id fromX) as u inner join Y as j onu.id=j.id) where explain ilike '%ReadFromRemoteParallelReplicas%';
89
+
selectcount() >0from (explain select*from (select id from X union allselect id fromZ) as u inner join Y as j onu.id=j.id) where explain ilike '%ReadFromRemoteParallelReplicas%'or explain ilike '%ReadFromParallelReplicas%';
79
90
80
91
-- The same for a `UNION` nested inside another `UNION`, which requires the descent to be recursive.
81
92
set parallel_replicas_for_queries_with_multiple_tables=1;
82
-
selectcount() from (explain select*from (select id from X union all (select id fromXunion allselect id fromX)) as u inner join Y as j onu.id=j.id) where explain ilike '%ReadFromRemoteParallelReplicas%';
93
+
selectcount() >0from (explain select*from (select id from X union all (select id fromZunion allselect id fromW)) as u inner join Y as j onu.id=j.id) where explain ilike '%ReadFromRemoteParallelReplicas%'or explain ilike '%ReadFromParallelReplicas%';
83
94
set parallel_replicas_for_queries_with_multiple_tables=0;
84
-
selectcount() from (explain select*from (select id from X union all (select id fromXunion allselect id fromX)) as u inner join Y as j onu.id=j.id) where explain ilike '%ReadFromRemoteParallelReplicas%';
95
+
selectcount() >0from (explain select*from (select id from X union all (select id fromZunion allselect id fromW)) as u inner join Y as j onu.id=j.id) where explain ilike '%ReadFromRemoteParallelReplicas%'or explain ilike '%ReadFromParallelReplicas%';
0 commit comments