mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 09:32:01 +00:00
dbms: development [#CONV-2944].
This commit is contained in:
parent
c255980539
commit
32d28c0384
@ -48,8 +48,14 @@ public:
|
|||||||
void dumpTree(std::ostream & ostr, size_t indent = 0);
|
void dumpTree(std::ostream & ostr, size_t indent = 0);
|
||||||
void dumpTreeWithProfile(std::ostream & ostr, size_t indent = 0);
|
void dumpTreeWithProfile(std::ostream & ostr, size_t indent = 0);
|
||||||
|
|
||||||
|
/// Получить листовые источники (не считая этот).
|
||||||
|
BlockInputStreams getLeaves();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BlockInputStreams children;
|
BlockInputStreams children;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void getLeavesImpl(BlockInputStreams & res, BlockInputStreamPtr this_shared_ptr = NULL);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,5 +50,27 @@ String IBlockInputStream::getShortName() const
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BlockInputStreams IBlockInputStream::getLeaves()
|
||||||
|
{
|
||||||
|
BlockInputStreams res;
|
||||||
|
getLeavesImpl(res);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void IBlockInputStream::getLeavesImpl(BlockInputStreams & res, BlockInputStreamPtr this_shared_ptr)
|
||||||
|
{
|
||||||
|
if (children.empty())
|
||||||
|
{
|
||||||
|
if (this_shared_ptr)
|
||||||
|
res.push_back(this_shared_ptr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
for (BlockInputStreams::iterator it = children.begin(); it != children.end(); ++it)
|
||||||
|
(*it)->getLeavesImpl(res, *it);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
|
#include <iomanip>
|
||||||
|
|
||||||
#include <Poco/URI.h>
|
#include <Poco/URI.h>
|
||||||
#include <Poco/NumberParser.h>
|
#include <Poco/NumberParser.h>
|
||||||
|
|
||||||
|
#include <statdaemons/Stopwatch.h>
|
||||||
|
|
||||||
#include <DB/Core/ErrorCodes.h>
|
#include <DB/Core/ErrorCodes.h>
|
||||||
|
|
||||||
#include <DB/IO/ReadBufferFromIStream.h>
|
#include <DB/IO/ReadBufferFromIStream.h>
|
||||||
@ -8,6 +12,8 @@
|
|||||||
#include <DB/IO/WriteBufferFromString.h>
|
#include <DB/IO/WriteBufferFromString.h>
|
||||||
#include <DB/IO/WriteHelpers.h>
|
#include <DB/IO/WriteHelpers.h>
|
||||||
|
|
||||||
|
#include <DB/DataStreams/IProfilingBlockInputStream.h>
|
||||||
|
|
||||||
#include <DB/Interpreters/executeQuery.h>
|
#include <DB/Interpreters/executeQuery.h>
|
||||||
|
|
||||||
#include "Handler.h"
|
#include "Handler.h"
|
||||||
@ -45,7 +51,9 @@ void HTTPRequestHandler::processQuery(Poco::Net::NameValueCollection & params, s
|
|||||||
if (params.has("max_threads"))
|
if (params.has("max_threads"))
|
||||||
context.settings.max_threads = Poco::NumberParser::parseUnsigned(params.get("max_threads"));
|
context.settings.max_threads = Poco::NumberParser::parseUnsigned(params.get("max_threads"));
|
||||||
|
|
||||||
|
Stopwatch watch;
|
||||||
executeQuery(in, out, context, query_plan);
|
executeQuery(in, out, context, query_plan);
|
||||||
|
watch.stop();
|
||||||
|
|
||||||
if (query_plan)
|
if (query_plan)
|
||||||
{
|
{
|
||||||
@ -53,6 +61,28 @@ void HTTPRequestHandler::processQuery(Poco::Net::NameValueCollection & params, s
|
|||||||
log_str << "Query plan:\n";
|
log_str << "Query plan:\n";
|
||||||
query_plan->dumpTree(log_str);
|
query_plan->dumpTree(log_str);
|
||||||
LOG_DEBUG(log, log_str.str());
|
LOG_DEBUG(log, log_str.str());
|
||||||
|
|
||||||
|
/// Выведем информацию о том, сколько считано строк и байт.
|
||||||
|
BlockInputStreams leaves = query_plan->getLeaves();
|
||||||
|
size_t rows = 0;
|
||||||
|
size_t bytes = 0;
|
||||||
|
|
||||||
|
for (BlockInputStreams::const_iterator it = leaves.begin(); it != leaves.end(); ++it)
|
||||||
|
{
|
||||||
|
if (const IProfilingBlockInputStream * profiling = dynamic_cast<const IProfilingBlockInputStream *>(&**it))
|
||||||
|
{
|
||||||
|
const BlockStreamProfileInfo & info = profiling->getInfo();
|
||||||
|
rows += info.rows;
|
||||||
|
bytes += info.bytes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rows != 0)
|
||||||
|
{
|
||||||
|
LOG_INFO(log, std::fixed << std::setprecision(3)
|
||||||
|
<< "Read " << rows << " rows, " << bytes / 1048576.0 << " MB in " << watch.elapsedSeconds() << " sec., "
|
||||||
|
<< static_cast<size_t>(rows / watch.elapsedSeconds()) << " rows/sec., " << bytes / 1048576.0 / watch.elapsedSeconds() << " MB/sec.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user