mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
Merge pull request #31806 from Algunenano/speedup_count
This commit is contained in:
commit
7a356bee44
@ -203,6 +203,21 @@ public:
|
||||
data(place).count += !assert_cast<const ColumnNullable &>(*columns[0]).isNullAt(row_num);
|
||||
}
|
||||
|
||||
void addBatchSinglePlace(
|
||||
size_t batch_size, AggregateDataPtr place, const IColumn ** columns, Arena *, ssize_t if_argument_pos) const override
|
||||
{
|
||||
auto & nc = assert_cast<const ColumnNullable &>(*columns[0]);
|
||||
if (if_argument_pos >= 0)
|
||||
{
|
||||
const auto & flags = assert_cast<const ColumnUInt8 &>(*columns[if_argument_pos]).getData();
|
||||
data(place).count += countBytesInFilterWithNull(flags, nc.getNullMapData().data());
|
||||
}
|
||||
else
|
||||
{
|
||||
data(place).count += batch_size - countBytesInFilter(nc.getNullMapData().data(), batch_size);
|
||||
}
|
||||
}
|
||||
|
||||
void merge(AggregateDataPtr __restrict place, ConstAggregateDataPtr rhs, Arena *) const override
|
||||
{
|
||||
data(place).count += data(rhs).count;
|
||||
|
@ -4,6 +4,8 @@
|
||||
<fill_query>INSERT INTO data SELECT number, 1 from numbers(10000000)</fill_query>
|
||||
|
||||
<query tag='count_10M' short='1'>SELECT count() FROM data</query>
|
||||
<query>SELECT count(k) FROM (SELECT k FROM data, numbers(20) _a)</query>
|
||||
<query>SELECT count(k) FROM (SELECT toNullable(k) as k FROM data, numbers(20) _a)</query>
|
||||
|
||||
<drop_query>DROP TABLE IF EXISTS data</drop_query>
|
||||
</test>
|
||||
|
@ -1,3 +1,21 @@
|
||||
<test>
|
||||
<query>SELECT countIf(number % 2) FROM numbers(100000000)</query>
|
||||
|
||||
<query>
|
||||
SELECT countIf(key IS NOT NULL)
|
||||
FROM
|
||||
(
|
||||
SELECT materialize(toNullable(1)) AS key
|
||||
FROM numbers(100000000)
|
||||
)
|
||||
</query>
|
||||
|
||||
<query>
|
||||
SELECT countIf(key IS NOT NULL)
|
||||
FROM
|
||||
(
|
||||
SELECT materialize(CAST(NULL, 'Nullable(Int8)')) AS key
|
||||
FROM numbers(100000000)
|
||||
)
|
||||
</query>
|
||||
</test>
|
||||
|
Loading…
Reference in New Issue
Block a user