2021-02-02 12:00:41 +00:00
|
|
|
|
---
|
|
|
|
|
toc_priority: 194
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
# uniqHLL12 {#agg_function-uniqhll12}
|
|
|
|
|
|
2021-03-06 09:19:23 +00:00
|
|
|
|
计算不同参数值的近似数量,使用 [HyperLogLog](https://en.wikipedia.org/wiki/HyperLogLog) 算法。
|
|
|
|
|
|
|
|
|
|
**语法**
|
2021-02-02 12:00:41 +00:00
|
|
|
|
|
|
|
|
|
``` sql
|
|
|
|
|
uniqHLL12(x[, ...])
|
|
|
|
|
```
|
|
|
|
|
|
2021-03-06 09:19:23 +00:00
|
|
|
|
**参数**
|
|
|
|
|
|
|
|
|
|
该函数采用可变数量的参数。 参数可以是 `Tuple`, `Array`, `Date`, `DateTime`, `String`,或数字类型。
|
2021-02-02 12:00:41 +00:00
|
|
|
|
|
2021-03-06 09:19:23 +00:00
|
|
|
|
**返回值**
|
2021-02-02 12:00:41 +00:00
|
|
|
|
|
2021-03-06 09:19:23 +00:00
|
|
|
|
**返回值**
|
2021-02-02 12:00:41 +00:00
|
|
|
|
|
2021-03-06 09:19:23 +00:00
|
|
|
|
- 一个[UInt64](../../../sql-reference/data-types/int-uint.md)类型的数字。
|
2021-02-02 12:00:41 +00:00
|
|
|
|
|
2021-03-06 09:19:23 +00:00
|
|
|
|
**实现细节**
|
2021-02-02 12:00:41 +00:00
|
|
|
|
|
2021-03-06 09:19:23 +00:00
|
|
|
|
功能:
|
2021-02-02 12:00:41 +00:00
|
|
|
|
|
2021-03-06 09:19:23 +00:00
|
|
|
|
- 计算聚合中所有参数的哈希值,然后在计算中使用它。
|
2021-02-02 12:00:41 +00:00
|
|
|
|
|
2021-03-06 09:19:23 +00:00
|
|
|
|
- 使用 HyperLogLog 算法来近似不同参数值的数量。
|
2021-02-02 12:00:41 +00:00
|
|
|
|
|
2021-03-06 09:19:23 +00:00
|
|
|
|
使用2^12个5比特单元。 状态的大小略大于2.5KB。 对于小数据集(<10K元素),结果不是很准确(误差高达10%)。 但是, 对于高基数数据集(10K-100M),结果相当准确,最大误差约为1.6%。Starting from 100M, the estimation error increases, and the function will return very inaccurate results for data sets with extremely high cardinality (1B+ elements).
|
2021-02-02 12:00:41 +00:00
|
|
|
|
|
2021-03-06 09:19:23 +00:00
|
|
|
|
- 提供确定结果(它不依赖于查询处理顺序)。
|
2021-02-02 12:00:41 +00:00
|
|
|
|
|
2021-03-06 09:19:23 +00:00
|
|
|
|
我们不建议使用此函数。 在大多数情况下, 使用 [uniq](../../../sql-reference/aggregate-functions/reference/uniq.md#agg_function-uniq) 或 [uniqCombined](../../../sql-reference/aggregate-functions/reference/uniqcombined.md#agg_function-uniqcombined) 函数。
|
2021-02-02 12:00:41 +00:00
|
|
|
|
|
2021-03-06 09:19:23 +00:00
|
|
|
|
**参见**
|
2021-02-02 12:00:41 +00:00
|
|
|
|
|
|
|
|
|
- [uniq](../../../sql-reference/aggregate-functions/reference/uniq.md#agg_function-uniq)
|
|
|
|
|
- [uniqCombined](../../../sql-reference/aggregate-functions/reference/uniqcombined.md#agg_function-uniqcombined)
|
|
|
|
|
- [uniqExact](../../../sql-reference/aggregate-functions/reference/uniqexact.md#agg_function-uniqexact)
|