Skip to content

Commit 775b7d3

Browse files
authored
Merge pull request ClickHouse#79401 from ClickHouse/pr-lazy-materialization
Lazy Materialization with parallel replicas
2 parents 8e6ec83 + 87c3c15 commit 775b7d3

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-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: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
LazilyRead (Lazily Read)
2+
0
3+
1 blob_
4+
2 blob_blob_
5+
3 blob_blob_blob_
6+
4 blob_blob_blob_blob_
7+
5 blob_blob_blob_blob_blob_
8+
6 blob_blob_blob_blob_blob_blob_
9+
7 blob_blob_blob_blob_blob_blob_blob_
10+
8 blob_blob_blob_blob_blob_blob_blob_blob_
11+
9 blob_blob_blob_blob_blob_blob_blob_blob_blob_
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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=100;
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+
ORDER BY k ASC
15+
LIMIT 10 settings parallel_replicas_local_plan=1) where s ilike 'LazilyRead%';
16+
17+
SELECT
18+
v,
19+
blob
20+
FROM pr_tt
21+
ORDER BY k
22+
LIMIT 10;
23+
24+
DROP TABLE pr_tt;

0 commit comments

Comments
 (0)