Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements for fast count() after #7510 #7551

Merged
merged 1 commit into from
Oct 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions dbms/src/AggregateFunctions/AggregateFunctionCount.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ class AggregateFunctionCount final : public IAggregateFunctionDataHelper<Aggrega
}

const char * getHeaderFilePath() const override { return __FILE__; }

/// Reset the state to specified value. This function is not the part of common interface.
void set(AggregateDataPtr place, UInt64 new_count)
{
data(place).count = new_count;
}
};


Expand Down
6 changes: 1 addition & 5 deletions dbms/src/Interpreters/InterpreterSelectQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@
#include <Processors/Transforms/FinishSortingTransform.h>
#include <DataTypes/DataTypeAggregateFunction.h>
#include <DataStreams/materializeBlock.h>
#include <IO/MemoryReadWriteBuffer.h>


namespace DB
Expand Down Expand Up @@ -1313,10 +1312,7 @@ void InterpreterSelectQuery::executeFetchColumns(
agg_count.create(place);
SCOPE_EXIT(agg_count.destroy(place));

MemoryWriteBuffer out;
writeVarUInt(*num_rows, out);
auto in = out.tryGetReadBuffer();
agg_count.deserialize(place, *in, nullptr);
agg_count.set(place, *num_rows);

auto column = ColumnAggregateFunction::create(func);
column->insertFrom(place);
Expand Down