freq_agg()
The freq_agg
aggregate uses the SpaceSaving algorithm to estimate the most common elements of a set. This API takes a sizing parameter and a PostgreSQL column, and returns a FreqAgg object that can be passed to other freq_agg APIs.
warning
Experimental features could have bugs. They might not be backwards compatible, and could be removed in future releases. Use these features at your own risk, and do not use any experimental features in production.
Required arguments
Name | Type | Description |
---|---|---|
freq | DOUBLE PRECISION | Minimum frequency (0.0-1.0) needed to keep track of a value |
value | AnyElement | Column to aggregate |
Returns
Column | Type | Description |
---|---|---|
agg | SpaceSavingAggregate | An object storing the most common elements of the given table and their estimated frequency. |
Sample usage
This example creates frequency aggregate over a field ZIP
in a HomeSales
table. This aggregate tracks any ZIP
value that occurs in at least 5% of rows.
SELECT toolkit_experimental.freq_agg(0.05, ZIP) FROM HomeSales;
当前内容版权归 TimescaleDB 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 TimescaleDB .