NDV

Description

Syntax

NDV (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

  1. MySQL > select ndv(query_id) from log_statis group by datetime;
  2. +-----------------+
  3. | ndv(`query_id`) |
  4. +-----------------+
  5. | 17721 |
  6. +-----------------+

keyword NDV