CertKeen

Google Cloud Professional Data Engineer · Free practice question 10 of 12

Approximate distinct counts for dashboards

A dashboard at Wetherby Streaming shows daily unique viewers from a 40 TB BigQuery table, and the exact COUNT(DISTINCT viewer_id) query is slow and expensive. The product team accepts a small statistical error. What should the query use?

  1. A.COUNT(viewer_id)
  2. B.APPROX_COUNT_DISTINCT(viewer_id)
  3. C.COUNT(DISTINCT viewer_id) with a LIMIT clause
  4. D.SUM(1) grouped by viewer_id
Show answer and explanation

Correct answer: B. APPROX_COUNT_DISTINCT(viewer_id)

Why: APPROX_COUNT_DISTINCT uses a HyperLogLog-based estimate that needs far less memory and computation than an exact distinct count, at the cost of a small error. COUNT counts repeated viewers more than once. LIMIT does not reduce the work of the aggregation, and grouping by viewer_id still processes every distinct value.

More free Google Cloud Professional Data Engineer questions