A dashboard needs a fast, approximate count of unique visitors over billions of rows, where a small error margin is acceptable in exchange for much lower compute cost than an exact distinct count. Which function is the right choice?
Answer & explanation
Correct answer: C
WHY C: approx_count_distinct uses a HyperLogLog sketch to estimate cardinality with a small, bounded error at a fraction of the cost of an exact distinct count, which is ideal for billions of rows where approximation is acceptable.
WHY NOT A: An exact count(distinct ...) is not answered from table statistics; it has to shuffle and deduplicate the values, so it is more expensive at scale, not cheaper than a sketch.
WHY NOT B: count counts non-null rows, not distinct values, so it overcounts unique visitors.
WHY NOT D: Summing ids is meaningless as a measure of cardinality.
WHY NOT E: first returns a single value and estimates nothing about the distinct count.