mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
Added setting "use_index_for_in_with_subqueries_max_values" #2571
This commit is contained in:
parent
76e35959fb
commit
e6c293ab60
@ -1473,11 +1473,23 @@ void ExpressionAnalyzer::makeSetsForIndex()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ExpressionAnalyzer::tryMakeSetFromSubquery(const ASTPtr & subquery_or_table_name)
|
void ExpressionAnalyzer::tryMakeSetForIndexFromSubquery(const ASTPtr & subquery_or_table_name)
|
||||||
{
|
{
|
||||||
BlockIO res = interpretSubquery(subquery_or_table_name, context, subquery_depth + 1, {})->execute();
|
BlockIO res = interpretSubquery(subquery_or_table_name, context, subquery_depth + 1, {})->execute();
|
||||||
|
|
||||||
SetPtr set = std::make_shared<Set>(SizeLimits(settings.max_rows_in_set, settings.max_bytes_in_set, settings.set_overflow_mode), true);
|
SizeLimits set_for_index_size_limits;
|
||||||
|
if (settings.use_index_for_in_with_subqueries_max_values && settings.use_index_for_in_with_subqueries_max_values < settings.max_rows_in_set)
|
||||||
|
{
|
||||||
|
/// Silently cancel creating the set for index if the specific limit has been reached.
|
||||||
|
set_for_index_size_limits = SizeLimits(settings.use_index_for_in_with_subqueries_max_values, settings.max_bytes_in_set, OverflowMode::BREAK);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/// If the limit specific for set for index is lower than general limits for set - use general limit.
|
||||||
|
set_for_index_size_limits = SizeLimits(settings.max_rows_in_set, settings.max_bytes_in_set, settings.set_overflow_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
SetPtr set = std::make_shared<Set>(set_for_index_size_limits, true);
|
||||||
|
|
||||||
set->setHeader(res.in->getHeader());
|
set->setHeader(res.in->getHeader());
|
||||||
while (Block block = res.in->read())
|
while (Block block = res.in->read())
|
||||||
@ -1521,7 +1533,7 @@ void ExpressionAnalyzer::makeSetsForIndexImpl(const ASTPtr & node, const Block &
|
|||||||
if (typeid_cast<ASTSubquery *>(arg.get()) || typeid_cast<ASTIdentifier *>(arg.get()))
|
if (typeid_cast<ASTSubquery *>(arg.get()) || typeid_cast<ASTIdentifier *>(arg.get()))
|
||||||
{
|
{
|
||||||
if (settings.use_index_for_in_with_subqueries)
|
if (settings.use_index_for_in_with_subqueries)
|
||||||
tryMakeSetFromSubquery(arg);
|
tryMakeSetForIndexFromSubquery(arg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -345,7 +345,7 @@ private:
|
|||||||
* Create Set from a subuqery or a table expression in the query. The created set is suitable for using the index.
|
* Create Set from a subuqery 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.
|
* The set will not be created if its size hits the limit.
|
||||||
*/
|
*/
|
||||||
void tryMakeSetFromSubquery(const ASTPtr & subquery_or_table_name);
|
void tryMakeSetForIndexFromSubquery(const ASTPtr & subquery_or_table_name);
|
||||||
|
|
||||||
void makeSetsForIndexImpl(const ASTPtr & node, const Block & sample_block);
|
void makeSetsForIndexImpl(const ASTPtr & node, const Block & sample_block);
|
||||||
|
|
||||||
|
@ -187,6 +187,7 @@ struct Settings
|
|||||||
M(SettingSeconds, http_receive_timeout, DEFAULT_HTTP_READ_BUFFER_TIMEOUT, "HTTP receive timeout") \
|
M(SettingSeconds, http_receive_timeout, DEFAULT_HTTP_READ_BUFFER_TIMEOUT, "HTTP receive timeout") \
|
||||||
M(SettingBool, optimize_throw_if_noop, false, "If setting is enabled and OPTIMIZE query didn't actually assign a merge then an explanatory exception is thrown") \
|
M(SettingBool, optimize_throw_if_noop, false, "If setting is enabled and OPTIMIZE query didn't actually assign a merge then an explanatory exception is thrown") \
|
||||||
M(SettingBool, use_index_for_in_with_subqueries, true, "Try using an index if there is a subquery or a table expression on the right side of the IN operator.") \
|
M(SettingBool, use_index_for_in_with_subqueries, true, "Try using an index if there is a subquery or a table expression on the right side of the IN operator.") \
|
||||||
|
M(SettingUInt64, use_index_for_in_with_subqueries_max_values, 100000, "Don't use index of a table for filtering by right hand size of the IN operator if the size of set is larger than specified threshold. This allows to avoid performance degradation and higher memory usage due to preparation of additional data structures.") \
|
||||||
\
|
\
|
||||||
M(SettingBool, empty_result_for_aggregation_by_empty_set, false, "Return empty result when aggregating without keys on empty set.") \
|
M(SettingBool, empty_result_for_aggregation_by_empty_set, false, "Return empty result when aggregating without keys on empty set.") \
|
||||||
M(SettingBool, allow_distributed_ddl, true, "If it is set to true, then a user is allowed to executed distributed DDL queries.") \
|
M(SettingBool, allow_distributed_ddl, true, "If it is set to true, then a user is allowed to executed distributed DDL queries.") \
|
||||||
|
Loading…
Reference in New Issue
Block a user