- HLL is empty. No value is inserted into HLL and the storage cost is the lowest, which is 80 bytes.
- The number of distinct hash values in HLL is less than or equal to 160. The highest storage cost is 1360 bytes (80 + 160 * 8 = 1360).
- The number of distinct hash values in HLL is greater than 160. The storage cost is fixed at 16,464 bytes (80 + 16 * 1024 = 16464).
- Data volume: HLL returns an approximate value. A larger data volume results in a more accurate result. A smaller data volume results in larger deviation.
- Data distribution: In the case of large data volume and high-cardinality dimension column for GROUP BY, data computation will use more memory. HLL is not recommended in this situation. It is recommended when you perform no-group-by count distinct or GROUP BY on low-cardinality dimension columns.
- Query granularity: If you query data at a large query granularity, we recommend you use the Aggregate table or materialized view to pre-aggregate data to reduce data volume.
Related functions
- HLL_UNION_AGG(hll): This function is an aggregate function used to estimate the cardinality of all data that meet the conditions. This can also be used to analyze functions. It only supports default window and does not support window clause.
- HLL_RAW_AGG(hll): This function is an aggregate function used to aggregate fields of hll type and returns with hll type.
- HLL_CARDINALITY(hll): This function is used to estimate the cardinality of a single hll column.
- HLL_HASH(column_name): This generates HLL column type and is used for inserts or imports. See the instructions for the use of imports.
- HLL_EMPTY: This generates empty HLL column and is used to fill in default values during inserts or imports. See the instructions for the use of imports.
Examples
-
Create a table with HLL columns
set1andset2. -
Load data by using Stream Load.
text
-
Aggregate data in the following three ways: (Without aggregation, direct query on base table may be as slow as using approx_count_distinct)
-
Query data. HLL columns do not support direct query to its original values. It can be queried by matching functions.
text