-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support incremental t-digest updates
The existing code allows merging of pre-calculated tdigest values, which is good enough for rollup use cases. But it does not work too well for cases that require incremental updates, when the digest is updated with individual values. This adds two new functions tdigest_add and tdigest_union that support these incremental updates. With tdigest_add() it's possible to add a single value to the tdigest value UPDATE t SET digest = tdigest_add(digest, x, 100); or an array of values UPDATE t SET digest = tdigest_add(digest, ARRAY[x, y, z], 100); while tdigest_union allows() 'merging' two digests: UPDATE t SET digest = tdigest_union(digest1, digest2); The idea is similar to hll_add/hll_union from the HLL extension, and we might even add the same || operator for tdigest_union. For tdigest_add that may not be possible, because we need to specify the compression for cases where there's no initial tdigest (i.e. tdigest_add(NULL,x)), and operators only allow two parameters. The tdigest_add function may be rather inefficient, because it requires deserialization, compaction and serialization for each call. This is particularly true for the single-value variant. To mitigate this, use the variant with an array of values, or possibly the tdigest_union. Based on proposal/discussion with sporty81 (Matt Watson).
- Loading branch information
Showing
7 changed files
with
450 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.