APPROX_COUNT_DISTINCT
APPROX_COUNT_DISTINCTβ
Descriptionβ
Syntaxβ
APPROX_COUNT_DISTINCT (expr)
Returns an approximate aggregation function similar to the result of COUNT (DISTINCT col).
It combines COUNT and DISTINCT faster and uses fixed-size memory, so less memory can be used for columns with high cardinality.
exampleβ
MySQL > select approx_count_distinct(query_id) from log_statis group by datetime;
+-----------------+
| approx_count_distinct(`query_id`) |
+-----------------+
| 17721 |
+-----------------+
keywordsβ
APPROX_COUNT_DISTINCT