mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
Use opd prewhere optimizaer for old analyzer.
This commit is contained in:
parent
7575f0db84
commit
1063d9ca50
@ -600,7 +600,7 @@ InterpreterSelectQuery::InterpreterSelectQuery(
|
||||
query.setFinal();
|
||||
}
|
||||
|
||||
auto analyze = [&] (bool)
|
||||
auto analyze = [&] (bool try_move_to_prewhere)
|
||||
{
|
||||
/// Allow push down and other optimizations for VIEW: replace with subquery and rewrite it.
|
||||
ASTPtr view_table;
|
||||
@ -632,37 +632,37 @@ InterpreterSelectQuery::InterpreterSelectQuery(
|
||||
view = nullptr;
|
||||
}
|
||||
|
||||
// if (try_move_to_prewhere
|
||||
// && storage && storage->canMoveConditionsToPrewhere()
|
||||
// && query.where() && !query.prewhere()
|
||||
// && !query.hasJoin()) /// Join may produce rows with nulls or default values, it's difficult to analyze if they affected or not.
|
||||
// {
|
||||
// /// PREWHERE optimization: transfer some condition from WHERE to PREWHERE if enabled and viable
|
||||
// if (const auto & column_sizes = storage->getColumnSizes(); !column_sizes.empty())
|
||||
// {
|
||||
// /// Extract column compressed sizes.
|
||||
// std::unordered_map<std::string, UInt64> column_compressed_sizes;
|
||||
// for (const auto & [name, sizes] : column_sizes)
|
||||
// column_compressed_sizes[name] = sizes.data_compressed;
|
||||
if (try_move_to_prewhere
|
||||
&& storage && storage->canMoveConditionsToPrewhere()
|
||||
&& query.where() && !query.prewhere()
|
||||
&& !query.hasJoin()) /// Join may produce rows with nulls or default values, it's difficult to analyze if they affected or not.
|
||||
{
|
||||
/// PREWHERE optimization: transfer some condition from WHERE to PREWHERE if enabled and viable
|
||||
if (const auto & column_sizes = storage->getColumnSizes(); !column_sizes.empty())
|
||||
{
|
||||
/// Extract column compressed sizes.
|
||||
std::unordered_map<std::string, UInt64> column_compressed_sizes;
|
||||
for (const auto & [name, sizes] : column_sizes)
|
||||
column_compressed_sizes[name] = sizes.data_compressed;
|
||||
|
||||
// SelectQueryInfo current_info;
|
||||
// current_info.query = query_ptr;
|
||||
// current_info.syntax_analyzer_result = syntax_analyzer_result;
|
||||
SelectQueryInfo current_info;
|
||||
current_info.query = query_ptr;
|
||||
current_info.syntax_analyzer_result = syntax_analyzer_result;
|
||||
|
||||
// Names queried_columns = syntax_analyzer_result->requiredSourceColumns();
|
||||
// const auto & supported_prewhere_columns = storage->supportedPrewhereColumns();
|
||||
Names queried_columns = syntax_analyzer_result->requiredSourceColumns();
|
||||
const auto & supported_prewhere_columns = storage->supportedPrewhereColumns();
|
||||
|
||||
// MergeTreeWhereOptimizer where_optimizer{
|
||||
// std::move(column_compressed_sizes),
|
||||
// metadata_snapshot,
|
||||
// storage->getConditionEstimatorByPredicate(query_info, storage_snapshot, context),
|
||||
// queried_columns,
|
||||
// supported_prewhere_columns,
|
||||
// log};
|
||||
MergeTreeWhereOptimizer where_optimizer{
|
||||
std::move(column_compressed_sizes),
|
||||
metadata_snapshot,
|
||||
storage->getConditionEstimatorByPredicate(query_info, storage_snapshot, context),
|
||||
queried_columns,
|
||||
supported_prewhere_columns,
|
||||
log};
|
||||
|
||||
// where_optimizer.optimize(current_info, context);
|
||||
// }
|
||||
// }
|
||||
where_optimizer.optimize(current_info, context);
|
||||
}
|
||||
}
|
||||
|
||||
if (query.prewhere() && query.where())
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user