quantile
Percentile estimates — p50, p95, p99 for latency and performance metrics.
Signature
quantile(level)(column): Float64Returns
Float64
What it does
Computes an approximate quantile at the specified level (0–1) using a reservoir sampling algorithm. quantile(0.95)(latency) gives the p95 latency. quantiles(0.5, 0.95, 0.99)(col) returns all levels in one pass.
quantile() uses a t-digest algorithm by default in ClickHouse, providing accurate percentile estimates without storing all values. It is the standard way to monitor SLA compliance (p99 < 200ms), analyse response time distributions, and build performance dashboards. quantiles() (plural) computes multiple percentiles in a single pass — always prefer it over multiple quantile() calls.
Notes
- quantiles(0.5, 0.95, 0.99)(col) returns an Array — one pass for all percentiles.
- For exact quantiles use quantileExact() — accurate but uses O(n) memory.
- quantileTDigest() is the default algorithm. quantileDDSketch() is more accurate at extreme tails.
Example SQL
quantile in ClickHouse SQL
TypeScript with hypequery
Use quantile in a typed TypeScript query
hypequery gives you a type-safe query builder for ClickHouse. The generated schema maps your ClickHouse columns to TypeScript types, and raw SQL expressions let you incorporate functions like quantile when you need them inside a builder query.
Common questions
What developers search for with quantile
ClickHouse p99 latency query
quantile(0.99)(response_ms) in a GROUP BY hour query gives hourly p99 latency. Use quantiles(0.5,0.95,0.99) to get all three in one pass.
ClickHouse percentile TypeScript
Pass quantile expressions as raw SQL in hypequery's .select() or .groupBy() to get typed results back in your TypeScript application.
FAQ
Frequently asked questions about quantile
How accurate is quantile() in ClickHouse?
quantile() uses t-digest and is typically accurate to within 1% of the true percentile. For exact values, use quantileExact() at the cost of higher memory usage.
What is the difference between quantile() and quantiles()?
quantile(level)(col) returns a single Float64. quantiles(l1, l2, ...)(col) returns an Array of all requested levels in one scan — always use quantiles() when you need more than one percentile.
Related guides
Next step
Use quantile in a type-safe TypeScript query
hypequery generates TypeScript types from your ClickHouse schema. Use quantile alongside the builder, and reach for raw SQL expressions when the function is not exposed as a dedicated helper.