> ## Documentation Index
> Fetch the complete documentation index at: https://clickhouse.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> 一定の精度で、数値の数列に対する複数の分位点を異なるレベルで同時に計算します。

# quantilesTiming

<div id="quantilesTiming">
  ## quantilesTiming
</div>

導入バージョン: v1.1.0

一定の精度で、異なるレベルにおける数値データ列の複数の [分位点](https://en.wikipedia.org/wiki/Quantile) を同時に計算します。

この関数は [`quantileTiming`](/docs/ja/reference/functions/aggregate-functions/quantileTiming) と同等ですが、1 回の処理で複数の分位レベルを計算できるため、個別に分位点関数を呼び出すよりも効率的です。

結果は決定論的です (クエリ処理の順序に依存しません) 。この関数は、Web ページの読み込み時間や backend の応答時間のような分布を表す数列を扱うのに最適化されています。

**精度**

計算結果が正確になるのは、次の場合です。

* 値の総数が 5670 を超えない場合。
* 値の総数が 5670 を超えていても、ページの読み込み時間が 1024ms 未満の場合。

それ以外の場合、計算結果は 16 ms 単位で最も近い値に丸められます。

<Note>
  ページの読み込み時間の分位点を計算する場合、この関数は [`quantiles`](/docs/ja/reference/functions/aggregate-functions/quantiles) よりも効率的かつ高精度です。
</Note>

**構文**

```sql theme={null}
quantilesTiming(level1, level2, ...)(expr)
```

**パラメータ**

* `level` — 分位点のレベル。0 から 1 の定数の浮動小数点数を 1 つ以上指定します。`level` の値には `[0.01, 0.99]` の範囲を使用することを推奨します。 [`Float*`](/docs/ja/reference/data-types/float)

**引数**

* `expr` — カラムの値に対する式で、結果の data type が数値データ型、`Date`、または `DateTime` になるもの。関数に負の値を渡した場合の動作は未定義です。値が 30,000 を超える場合 (ページの読み込み時間が 30 秒を超える場合) は、30,000 として扱われます。 [`(U)Int*`](/docs/ja/reference/data-types/int-uint) or [`Float*`](/docs/ja/reference/data-types/float) or [`Date`](/docs/ja/reference/data-types/date) or [`DateTime`](/docs/ja/reference/data-types/datetime)

**戻り値**

指定したレベルの分位点を、レベルの指定順と同じ順序で格納した Array。 [`Array(Float32)`](/docs/ja/reference/data-types/array)

**例**

**複数のタイミング分位点を計算する**

```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 quantilesTiming(0.25, 0.5, 0.75)(response_time) FROM t;
```

```response title=Response theme={null}
┌─quantilesTiming(0.25, 0.5, 0.75)(response_time)─┐
│ [108,126,168]                                   │
└─────────────────────────────────────────────────┘
```
