mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Add special setting to show indexes.
This commit is contained in:
parent
6fe3470893
commit
23089a2fec
@ -129,6 +129,7 @@ struct QueryPlanSettings
|
||||
{"header", query_plan_options.header},
|
||||
{"description", query_plan_options.description},
|
||||
{"actions", query_plan_options.actions},
|
||||
{"indexes", query_plan_options.indexes},
|
||||
{"optimize", optimize},
|
||||
};
|
||||
};
|
||||
|
@ -99,6 +99,9 @@ public:
|
||||
/// Get detailed description of step actions. This is shown in EXPLAIN query with options `actions = 1`.
|
||||
virtual void describeActions(FormatSettings & /*settings*/) const {}
|
||||
|
||||
/// Get detailed description of read-from-storage step indexes (if any). Shown in with options `indexes = 1`.
|
||||
virtual void describeIndexes(FormatSettings & /*settings*/) const {}
|
||||
|
||||
/// Get description of processors added in current step. Should be called after updatePipeline().
|
||||
virtual void describePipeline(FormatSettings & /*settings*/) const {}
|
||||
|
||||
|
@ -243,6 +243,9 @@ static void explainStep(
|
||||
|
||||
if (options.actions)
|
||||
step.describeActions(settings);
|
||||
|
||||
if (options.indexes)
|
||||
step.describeIndexes(settings);
|
||||
}
|
||||
|
||||
std::string debugExplainStep(const IQueryPlanStep & step)
|
||||
|
@ -66,6 +66,8 @@ public:
|
||||
bool description = true;
|
||||
/// Add detailed information about step actions.
|
||||
bool actions = false;
|
||||
/// Add information about indexes actions.
|
||||
bool indexes = false;
|
||||
};
|
||||
|
||||
struct ExplainPipelineOptions
|
||||
|
@ -191,6 +191,16 @@ void ReadFromMergeTree::describeActions(FormatSettings & format_settings) const
|
||||
std::string prefix(format_settings.offset, format_settings.indent_char);
|
||||
format_settings.out << prefix << "ReadType: " << readTypeToString(read_type) << '\n';
|
||||
|
||||
if (index_stats && !index_stats->empty())
|
||||
{
|
||||
format_settings.out << prefix << "Parts: " << index_stats->back().num_parts_after << '\n';
|
||||
format_settings.out << prefix << "Granules: " << index_stats->back().num_granules_after << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
void ReadFromMergeTree::describeIndexes(FormatSettings & format_settings) const
|
||||
{
|
||||
std::string prefix(format_settings.offset, format_settings.indent_char);
|
||||
if (index_stats && !index_stats->empty())
|
||||
{
|
||||
std::string indent(format_settings.indent, format_settings.indent_char);
|
||||
@ -233,9 +243,6 @@ void ReadFromMergeTree::describeActions(FormatSettings & format_settings) const
|
||||
format_settings.out << '/' << (*index_stats)[i - 1].num_granules_after;
|
||||
format_settings.out << '\n';
|
||||
}
|
||||
|
||||
format_settings.out << prefix << "Parts: " << index_stats->back().num_parts_after << '\n';
|
||||
format_settings.out << prefix << "Granules: " << index_stats->back().num_granules_after << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,6 +85,7 @@ public:
|
||||
void initializePipeline(QueryPipeline & pipeline, const BuildQueryPipelineSettings &) override;
|
||||
|
||||
void describeActions(FormatSettings & format_settings) const override;
|
||||
void describeIndexes(FormatSettings & format_settings) const override;
|
||||
|
||||
private:
|
||||
const MergeTreeData & storage;
|
||||
|
@ -1,5 +1,4 @@
|
||||
ReadFromMergeTree
|
||||
ReadType: Default
|
||||
Indexes:
|
||||
MinMax
|
||||
Keys:
|
||||
@ -31,45 +30,13 @@
|
||||
Description: set GRANULARITY 2
|
||||
Parts: 1/1
|
||||
Granules: 1/2
|
||||
Parts: 1
|
||||
Granules: 1
|
||||
-----------------
|
||||
ReadFromMergeTree
|
||||
ReadType: InOrder
|
||||
Indexes:
|
||||
MinMax
|
||||
Description: true
|
||||
Parts: 5/5
|
||||
Granules: 12/12
|
||||
Partition
|
||||
Description: true
|
||||
Parts: 5/5
|
||||
Granules: 12/12
|
||||
PrimaryKey
|
||||
Keys:
|
||||
x
|
||||
Description: (x in [16, +inf))
|
||||
Parts: 1/5
|
||||
Granules: 3/12
|
||||
Parts: 1
|
||||
Granules: 3
|
||||
-----------------
|
||||
ReadFromMergeTree
|
||||
ReadType: InReverseOrder
|
||||
Indexes:
|
||||
MinMax
|
||||
Description: true
|
||||
Parts: 5/5
|
||||
Granules: 12/12
|
||||
Partition
|
||||
Description: true
|
||||
Parts: 5/5
|
||||
Granules: 12/12
|
||||
PrimaryKey
|
||||
Keys:
|
||||
x
|
||||
Description: (x in [16, +inf))
|
||||
Parts: 1/5
|
||||
Granules: 3/12
|
||||
Parts: 1
|
||||
Granules: 3
|
||||
|
@ -8,7 +8,7 @@ $CLICKHOUSE_CLIENT -q "create table test_index (x UInt32, y UInt32, z UInt32, t
|
||||
$CLICKHOUSE_CLIENT -q "insert into test_index select number, number > 3 ? 3 : number, number = 1 ? 1 : 0, number from numbers(20)"
|
||||
|
||||
$CLICKHOUSE_CLIENT -q "
|
||||
explain actions = 1 select *, _part from test_index where t % 19 = 16 and y > 0 and bitAnd(z, 3) != 1 and x > 10 and t % 20 > 14;
|
||||
explain indexes = 1 select *, _part from test_index where t % 19 = 16 and y > 0 and bitAnd(z, 3) != 1 and x > 10 and t % 20 > 14;
|
||||
" | grep -A 100 "ReadFromMergeTree" # | grep -v "Description"
|
||||
|
||||
echo "-----------------"
|
||||
|
Loading…
Reference in New Issue
Block a user