1. Read 10%
SAMPLE 0.1 reads roughly 10% of the data for a fast approximate result.
SAMPLE 0.1Typorithm · medium
Step 1 of 8 · intro card
Querying
SAMPLE 0.1 reads about 10% of the data for fast approximate aggregates, but the table must declare a sampling key in its ORDER BY / SAMPLE BY.
SAMPLE n reads only a fraction of the data, trading exactness for a large speedup on big tables.
Because only part of the data is read, counts and sums must be scaled up by 1 / fraction to estimate the total.
SAMPLE only works when the table was created with a sampling key, declared via ORDER BY together with SAMPLE BY.
SAMPLE 0.1 reads ~10% of data.
Scale counts by 1 / fraction.
Needs a sampling key in ORDER BY / SAMPLE BY.
SELECT count() * 10 AS estimated_total
FROM events
SAMPLE 0.1;Connect each part of the code to the concept before you type.
SAMPLE 0.1 reads roughly 10% of the data for a fast approximate result.
SAMPLE 0.1Multiply by 1 / fraction to extrapolate the sampled count to the full table.
count() * 10The table must declare a sampling key in ORDER BY / SAMPLE BY for SAMPLE to work.
FROM eventsRead the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.