VeloDB Cloud
SQL Manual
Functions
aggregate-functions
APPROX_COUNT_DISTINCT

APPROX_COUNT_DISTINCT

Description

Syntax:

APPROX_COUNT_DISTINCT (expr)

This function returns an approximate aggregation function similar to the result of COUNT (DISTINCT col).

It is faster than the combination of COUNT and DISTINCT and uses fixed-size memory, so it can reduce memory usage for high-cardinality columns.

Example

MySQL > select approx_count_distinct(query_id) from log_statis group by datetime;
+-----------------+
| approx_count_distinct(`query_id`) |
+-----------------+
| 17721           |
+-----------------+

Keywords

APPROX_COUNT_DISTINCT