mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Read prefix before blocks while executing subquery.
This commit is contained in:
parent
f635d2bd9b
commit
001e4daf25
@ -279,12 +279,14 @@ void ExpressionAnalyzer::tryMakeSetForIndexFromSubquery(const ASTPtr & subquery_
|
||||
SetPtr set = std::make_shared<Set>(settings.size_limits_for_set, true);
|
||||
set->setHeader(res.in->getHeader());
|
||||
|
||||
res.in->readPrefix();
|
||||
while (Block block = res.in->read())
|
||||
{
|
||||
/// If the limits have been exceeded, give up and let the default subquery processing actions take place.
|
||||
if (!set->insertFromBlock(block))
|
||||
return;
|
||||
}
|
||||
res.in->readSuffix();
|
||||
|
||||
prepared_sets[set_key] = std::move(set);
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ private:
|
||||
void assertAggregation() const;
|
||||
|
||||
/**
|
||||
* Create Set from a subuquery or a table expression in the query. The created set is suitable for using the index.
|
||||
* Create Set from a subquery or a table expression in the query. The created set is suitable for using the index.
|
||||
* The set will not be created if its size hits the limit.
|
||||
*/
|
||||
void tryMakeSetForIndexFromSubquery(const ASTPtr & subquery_or_table_name);
|
||||
|
@ -0,0 +1,10 @@
|
||||
0
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
@ -0,0 +1,9 @@
|
||||
DROP TABLE IF EXISTS tableFile_00968;
|
||||
DROP TABLE IF EXISTS tableMergeTree_00968;
|
||||
CREATE TABLE tableFile_00968(number UInt64) ENGINE = File('TSV');
|
||||
CREATE TABLE tableMergeTree_00968(id UInt64) ENGINE = MergeTree() PARTITION BY id ORDER BY id;
|
||||
|
||||
INSERT INTO tableFile_00968 SELECT number FROM system.numbers LIMIT 10;
|
||||
INSERT INTO tableMergeTree_00968 SELECT number FROM system.numbers LIMIT 100;
|
||||
|
||||
SELECT id FROM tableMergeTree_00968 WHERE id IN (SELECT number FROM tableFile_00968) ORDER BY id;
|
Loading…
Reference in New Issue
Block a user