> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-fix-nav-issues.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> With the determined precision computes the quantile of a numeric data sequence.

# quantileTiming

<h2 id="quantileTiming">
  quantileTiming
</h2>

Introduced in: v1.1.0

With the determined precision computes the [quantile](https://en.wikipedia.org/wiki/Quantile) of a numeric data sequence.

The result is deterministic (it does not depend on the query processing order).
The function is optimized for working with sequences which describe distributions like loading web pages times or backend response times.

When using multiple `quantile*` functions with different levels in a query, the internal states are not combined (that is, the query works less efficiently than it could).
In this case, use the [`quantiles`](/reference/functions/aggregate-functions/quantiles#quantiles) function.

**Accuracy**

The calculation is accurate if:

* Total number of values does not exceed 5670.
* Total number of values exceeds 5670, but the page loading time is less than 1024ms.

Otherwise, the result of the calculation is rounded to the nearest multiple of 16 ms.

<Note>
  For calculating page loading time quantiles, this function is more effective and accurate than [`quantile`](/reference/functions/aggregate-functions/quantile).
</Note>

<Note>
  If no values are passed to the function (when using `quantileTimingIf`), [NaN](/reference/data-types/float#nan-and-inf) is returned. The purpose of this is to differentiate these cases from cases that result in zero. See [ORDER BY clause](/reference/statements/select/order-by) for notes on sorting `NaN` values.
</Note>

**Syntax**

```sql theme={null}
quantileTiming(level)(expr)
```

**Aliases**: `medianTiming`

**Parameters**

* `level` — Optional. Level of quantile. Constant floating-point number from 0 to 1. We recommend using a `level` value in the range of `[0.01, 0.99]`. Default value: 0.5. At `level=0.5` the function calculates median. [`Float*`](/reference/data-types/float)

**Arguments**

* `expr` — Expression over a column values returning a Float\*-type number. If negative values are passed to the function, the behavior is undefined. If the value is greater than 30,000 (a page loading time of more than 30 seconds), it is assumed to be 30,000. [`Float*`](/reference/data-types/float)

**Returned value**

Quantile of the specified level. If no values are passed to the function (when using `quantileTimingIf`), NaN is returned. The purpose of this is to differentiate these cases from cases that result in zero. [`Float32`](/reference/data-types/float)

**Examples**

**Computing timing quantile**

```sql title=Query theme={null}
CREATE TABLE t (response_time UInt32) ENGINE = Memory;
INSERT INTO t VALUES (72), (112), (126), (145), (104), (242), (313), (168), (108);

SELECT quantileTiming(response_time) FROM t;
```

```response title=Response theme={null}
┌─quantileTiming(response_time)─┐
│                           126 │
└───────────────────────────────┘
```

**See Also**

* [median](/reference/functions/aggregate-functions/median)
* [quantiles](/reference/functions/aggregate-functions/quantiles)
