Computes an approximation of the count of distinct values with a specified expected relative error.
Syntax
1approx_count_distinct(<expression>[, <error>])
Arguments
Required
<expression>: An expression of any type to count distinct values for.
Optional
<error>: A double precision value specifying the expected relative error. Must be in the range (0.002, 1]. Defaults to 0.023 (2.3% expected relative error).
Returns
Returns a bigint representing the approximate count of distinct values.
Considerations
Faster than exact count(distinct expression) for large datasets.
The error parameter controls the trade-off between accuracy and performance.
Lower error values provide more accurate results but may require more computation.