Files
doris/docs/zh-CN/sql-reference/sql-functions/aggregate-functions/percentile_approx.md
ZhangYu0123 1d9b3aeee7 [Doc] Repair document format (#4336)
The error format '##keyword' in a lot of docs. This pr is to repair document format. #4335
2020-08-13 23:39:41 +08:00

2.1 KiB
Executable File

title, language
title language
PERCENTILE_APPROX zh-CN

PERCENTILE_APPROX

description

Syntax

PERCENTILE_APPROX(expr, DOUBLE p[, DOUBLE compression])

返回第p个百分位点的近似值,p的值介于0到1之间

compression参数是可选项,可设置范围是[2048, 10000],值越大,精度越高,内存消耗越大,计算耗时越长。 compression参数未指定或设置的值在[2048, 10000]范围外,以10000的默认值运行

该函数使用固定大小的内存,因此对于高基数的列可以使用更少的内存,可用于计算tp99等统计值

example

MySQL > select `table`, percentile_approx(cost_time,0.99) from log_statis group by `table`;
+---------------------+---------------------------+
| table    | percentile_approx(`cost_time`, 0.99) |
+----------+--------------------------------------+
| test     |                                54.22 |
+----------+--------------------------------------+

MySQL > select `table`, percentile_approx(cost_time,0.99, 4096) from log_statis group by `table`;
+---------------------+---------------------------+
| table    | percentile_approx(`cost_time`, 0.99, 4096.0) |
+----------+--------------------------------------+
| test     |                                54.21 |
+----------+--------------------------------------+
## keyword
PERCENTILE_APPROX,PERCENTILE,APPROX