Skip to content

Commit 965edc1

Browse files
committed
Lazy Materialization with parallel replicas
1 parent 3733458 commit 965edc1

File tree

3 files changed

+53
-3
lines changed

3 files changed

+53
-3
lines changed

src/Processors/QueryPlan/Optimizations/optimizeLazyMaterialization.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ static bool canUseLazyMaterializationForReadingStep(ReadFromMergeTree * reading)
2525
if (reading->isQueryWithSampling())
2626
return false;
2727

28-
if (reading->isParallelReadingEnabled())
29-
return false;
30-
3128
return true;
3229
}
3330

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
LazilyRead (Lazily Read)
2+
1 blob_
3+
2 blob_blob_
4+
3 blob_blob_blob_
5+
4 blob_blob_blob_blob_
6+
5 blob_blob_blob_blob_blob_
7+
6 blob_blob_blob_blob_blob_blob_
8+
7 blob_blob_blob_blob_blob_blob_blob_
9+
8 blob_blob_blob_blob_blob_blob_blob_blob_
10+
9 blob_blob_blob_blob_blob_blob_blob_blob_blob_
11+
999999 blob_blob_blob_blob_blob_blob_blob_blob_blob_
12+
999998 blob_blob_blob_blob_blob_blob_blob_blob_
13+
999997 blob_blob_blob_blob_blob_blob_blob_
14+
999996 blob_blob_blob_blob_blob_blob_
15+
999995 blob_blob_blob_blob_blob_
16+
999994 blob_blob_blob_blob_
17+
999993 blob_blob_blob_
18+
999992 blob_blob_
19+
999991 blob_
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
DROP TABLE IF EXISTS pr_tt;
2+
CREATE TABLE pr_tt (k UInt64, v String, blob String) ENGINE=MergeTree() ORDER BY tuple() settings index_granularity=10;
3+
INSERT INTO pr_tt SELECT number, toString(number), repeat('blob_', number % 10) FROM numbers(1_000_000);
4+
5+
-- make sure the optimization is enabled
6+
set query_plan_optimize_lazy_materialization=true, query_plan_max_limit_for_lazy_materialization=10;
7+
SET enable_parallel_replicas = 1, cluster_for_parallel_replicas = 'test_cluster_one_shard_three_replicas_localhost', parallel_replicas_for_non_replicated_merge_tree = 1;
8+
9+
select trimLeft(explain) as s from (EXPLAIN
10+
SELECT
11+
v,
12+
blob
13+
FROM pr_tt
14+
WHERE k % 10
15+
ORDER BY k ASC
16+
LIMIT 9 settings parallel_replicas_local_plan=1) where s ilike 'LazilyRead%';
17+
18+
SELECT
19+
v,
20+
blob
21+
FROM pr_tt
22+
WHERE k % 10
23+
ORDER BY k
24+
LIMIT 9;
25+
26+
SELECT
27+
v,
28+
blob
29+
FROM pr_tt
30+
WHERE k % 10
31+
ORDER BY k desc
32+
LIMIT 9;
33+
34+
DROP TABLE pr_tt;

0 commit comments

Comments
 (0)