Add bytes to result of EXPLAIN ESTIMATES

This commit is contained in:
Peng Jian 2021-07-09 19:17:03 +08:00
parent b526aacd56
commit fb793696a1
4 changed files with 18 additions and 10 deletions

View File

@ -87,7 +87,8 @@ Block InterpreterExplainQuery::getSampleBlock(const ASTExplainQuery::ExplainKind
{"table", std::make_shared<DataTypeString>()},
{"parts", std::make_shared<DataTypeUInt64>()},
{"rows", std::make_shared<DataTypeUInt64>()},
{"marks", std::make_shared<DataTypeUInt64>()}
{"marks", std::make_shared<DataTypeUInt64>()},
{"bytes", std::make_shared<DataTypeUInt64>()}
};
return Block({
{cols[0].type->createColumn(), cols[0].type, cols[0].name},
@ -95,6 +96,7 @@ Block InterpreterExplainQuery::getSampleBlock(const ASTExplainQuery::ExplainKind
{cols[2].type->createColumn(), cols[2].type, cols[2].name},
{cols[3].type->createColumn(), cols[3].type, cols[3].name},
{cols[4].type->createColumn(), cols[4].type, cols[4].name},
{cols[5].type->createColumn(), cols[5].type, cols[5].name},
});
}
else

View File

@ -443,9 +443,10 @@ void QueryPlan::explainEstimates(MutableColumns & columns)
{
std::string database_name;
std::string table_name;
Int64 parts = 0;
Int64 rows = 0;
Int64 marks = 0;
UInt64 parts = 0;
UInt64 rows = 0;
UInt64 marks = 0;
UInt64 bytes = 0;
EstimateCounters(const std::string & database, const std::string & table) : database_name(database), table_name(table)
{
}
@ -470,6 +471,7 @@ void QueryPlan::explainEstimates(MutableColumns & columns)
it->second->parts += step->getSelectedParts();
it->second->rows += step->getSelectedRows();
it->second->marks += step->getSelectedMarks();
it->second->bytes += step->getSelectedBytes();
}
for (const auto * child : node->children)
process_node(child);
@ -486,6 +488,7 @@ void QueryPlan::explainEstimates(MutableColumns & columns)
columns[index++]->insert(counter.second->parts);
columns[index++]->insert(counter.second->rows);
columns[index++]->insert(counter.second->marks);
columns[index++]->insert(counter.second->bytes);
}
}

View File

@ -118,6 +118,7 @@ ReadFromMergeTree::ReadFromMergeTree(
{
selected_marks += p->getMarksCount();
selected_rows += p->rows_count;
selected_bytes += p->getBytesOnDisk();
}
}

View File

@ -81,9 +81,10 @@ public:
void describeIndexes(JSONBuilder::JSONMap & map) const override;
const StorageID getStorageID() const { return data.getStorageID(); }
Int64 getSelectedParts() const { return selected_parts; }
Int64 getSelectedRows() const { return selected_rows; }
Int64 getSelectedMarks() const { return selected_marks; }
UInt64 getSelectedParts() const { return selected_parts; }
UInt64 getSelectedRows() const { return selected_rows; }
UInt64 getSelectedMarks() const { return selected_marks; }
UInt64 getSelectedBytes() const { return selected_bytes; }
private:
const MergeTreeReaderSettings reader_settings;
@ -110,9 +111,10 @@ private:
std::shared_ptr<PartitionIdToMaxBlock> max_block_numbers_to_read;
Poco::Logger * log;
Int64 selected_parts = 0;
Int64 selected_rows = 0;
Int64 selected_marks = 0;
UInt64 selected_parts = 0;
UInt64 selected_rows = 0;
UInt64 selected_marks = 0;
UInt64 selected_bytes = 0;
Pipe read(RangesInDataParts parts_with_range, Names required_columns, ReadType read_type, size_t max_streams, size_t min_marks_for_concurrent_read, bool use_uncompressed_cache);
Pipe readFromPool(RangesInDataParts parts_with_ranges, Names required_columns, size_t max_streams, size_t min_marks_for_concurrent_read, bool use_uncompressed_cache);