datasketches

datasketches

datasketches : Approximate analytics sketches and aggregates for PostgreSQL

Overview

ID Extension Package Version Category License Language
4690
datasketches
datasketches
1.7.0
FUNC
Apache-2.0
C++
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--s-d-r
No
Yes
No
Yes
yes
no

Built against Apache DataSketches C++ core 5.0.0.

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT
PIGSTY
1.7.0
18
17
16
15
14
datasketches -
RPM
PIGSTY
1.7.0
18
17
16
15
14
datasketches_$v -
DEB
PIGSTY
1.7.0
18
17
16
15
14
postgresql-$v-datasketches -
Linux / PG PG18 PG17 PG16 PG15 PG14
el8.x86_64
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
el8.aarch64
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
el9.x86_64
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
el9.aarch64
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
el10.x86_64
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
el10.aarch64
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
d12.x86_64
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
d12.aarch64
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
d13.x86_64
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
d13.aarch64
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
u22.x86_64
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
u22.aarch64
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
u24.x86_64
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
u24.aarch64
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
PIGSTY 1.7.0
Package Version OS ORG SIZE File URL
datasketches_18 1.7.0 el8.x86_64 pigsty 324.4 KiB datasketches_18-1.7.0-1PIGSTY.el8.x86_64.rpm
datasketches_18 1.7.0 el8.aarch64 pigsty 314.1 KiB datasketches_18-1.7.0-1PIGSTY.el8.aarch64.rpm
datasketches_18 1.7.0 el9.x86_64 pigsty 309.4 KiB datasketches_18-1.7.0-1PIGSTY.el9.x86_64.rpm
datasketches_18 1.7.0 el9.aarch64 pigsty 315.1 KiB datasketches_18-1.7.0-1PIGSTY.el9.aarch64.rpm
datasketches_18 1.7.0 el10.x86_64 pigsty 319.1 KiB datasketches_18-1.7.0-1PIGSTY.el10.x86_64.rpm
datasketches_18 1.7.0 el10.aarch64 pigsty 319.4 KiB datasketches_18-1.7.0-1PIGSTY.el10.aarch64.rpm
postgresql-18-datasketches 1.7.0 d12.x86_64 pigsty 918.1 KiB postgresql-18-datasketches_1.7.0-1PIGSTY~bookworm_amd64.deb
postgresql-18-datasketches 1.7.0 d12.aarch64 pigsty 920.0 KiB postgresql-18-datasketches_1.7.0-1PIGSTY~bookworm_arm64.deb
postgresql-18-datasketches 1.7.0 d13.x86_64 pigsty 943.3 KiB postgresql-18-datasketches_1.7.0-1PIGSTY~trixie_amd64.deb
postgresql-18-datasketches 1.7.0 d13.aarch64 pigsty 944.0 KiB postgresql-18-datasketches_1.7.0-1PIGSTY~trixie_arm64.deb
postgresql-18-datasketches 1.7.0 u22.x86_64 pigsty 1017.0 KiB postgresql-18-datasketches_1.7.0-1PIGSTY~jammy_amd64.deb
postgresql-18-datasketches 1.7.0 u22.aarch64 pigsty 1020.8 KiB postgresql-18-datasketches_1.7.0-1PIGSTY~jammy_arm64.deb
postgresql-18-datasketches 1.7.0 u24.x86_64 pigsty 977.8 KiB postgresql-18-datasketches_1.7.0-1PIGSTY~noble_amd64.deb
postgresql-18-datasketches 1.7.0 u24.aarch64 pigsty 991.3 KiB postgresql-18-datasketches_1.7.0-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
datasketches_17 1.7.0 el8.x86_64 pigsty 324.4 KiB datasketches_17-1.7.0-1PIGSTY.el8.x86_64.rpm
datasketches_17 1.7.0 el8.aarch64 pigsty 314.1 KiB datasketches_17-1.7.0-1PIGSTY.el8.aarch64.rpm
datasketches_17 1.7.0 el9.x86_64 pigsty 309.4 KiB datasketches_17-1.7.0-1PIGSTY.el9.x86_64.rpm
datasketches_17 1.7.0 el9.aarch64 pigsty 315.0 KiB datasketches_17-1.7.0-1PIGSTY.el9.aarch64.rpm
datasketches_17 1.7.0 el10.x86_64 pigsty 319.1 KiB datasketches_17-1.7.0-1PIGSTY.el10.x86_64.rpm
datasketches_17 1.7.0 el10.aarch64 pigsty 319.4 KiB datasketches_17-1.7.0-1PIGSTY.el10.aarch64.rpm
postgresql-17-datasketches 1.7.0 d12.x86_64 pigsty 918.3 KiB postgresql-17-datasketches_1.7.0-1PIGSTY~bookworm_amd64.deb
postgresql-17-datasketches 1.7.0 d12.aarch64 pigsty 919.2 KiB postgresql-17-datasketches_1.7.0-1PIGSTY~bookworm_arm64.deb
postgresql-17-datasketches 1.7.0 d13.x86_64 pigsty 942.9 KiB postgresql-17-datasketches_1.7.0-1PIGSTY~trixie_amd64.deb
postgresql-17-datasketches 1.7.0 d13.aarch64 pigsty 943.8 KiB postgresql-17-datasketches_1.7.0-1PIGSTY~trixie_arm64.deb
postgresql-17-datasketches 1.7.0 u22.x86_64 pigsty 1.1 MiB postgresql-17-datasketches_1.7.0-1PIGSTY~jammy_amd64.deb
postgresql-17-datasketches 1.7.0 u22.aarch64 pigsty 1.1 MiB postgresql-17-datasketches_1.7.0-1PIGSTY~jammy_arm64.deb
postgresql-17-datasketches 1.7.0 u24.x86_64 pigsty 977.8 KiB postgresql-17-datasketches_1.7.0-1PIGSTY~noble_amd64.deb
postgresql-17-datasketches 1.7.0 u24.aarch64 pigsty 991.2 KiB postgresql-17-datasketches_1.7.0-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
datasketches_16 1.7.0 el8.x86_64 pigsty 324.4 KiB datasketches_16-1.7.0-1PIGSTY.el8.x86_64.rpm
datasketches_16 1.7.0 el8.aarch64 pigsty 314.1 KiB datasketches_16-1.7.0-1PIGSTY.el8.aarch64.rpm
datasketches_16 1.7.0 el9.x86_64 pigsty 309.4 KiB datasketches_16-1.7.0-1PIGSTY.el9.x86_64.rpm
datasketches_16 1.7.0 el9.aarch64 pigsty 315.0 KiB datasketches_16-1.7.0-1PIGSTY.el9.aarch64.rpm
datasketches_16 1.7.0 el10.x86_64 pigsty 319.1 KiB datasketches_16-1.7.0-1PIGSTY.el10.x86_64.rpm
datasketches_16 1.7.0 el10.aarch64 pigsty 319.3 KiB datasketches_16-1.7.0-1PIGSTY.el10.aarch64.rpm
postgresql-16-datasketches 1.7.0 d12.x86_64 pigsty 918.1 KiB postgresql-16-datasketches_1.7.0-1PIGSTY~bookworm_amd64.deb
postgresql-16-datasketches 1.7.0 d12.aarch64 pigsty 919.5 KiB postgresql-16-datasketches_1.7.0-1PIGSTY~bookworm_arm64.deb
postgresql-16-datasketches 1.7.0 d13.x86_64 pigsty 943.1 KiB postgresql-16-datasketches_1.7.0-1PIGSTY~trixie_amd64.deb
postgresql-16-datasketches 1.7.0 d13.aarch64 pigsty 943.8 KiB postgresql-16-datasketches_1.7.0-1PIGSTY~trixie_arm64.deb
postgresql-16-datasketches 1.7.0 u22.x86_64 pigsty 1.1 MiB postgresql-16-datasketches_1.7.0-1PIGSTY~jammy_amd64.deb
postgresql-16-datasketches 1.7.0 u22.aarch64 pigsty 1.1 MiB postgresql-16-datasketches_1.7.0-1PIGSTY~jammy_arm64.deb
postgresql-16-datasketches 1.7.0 u24.x86_64 pigsty 977.8 KiB postgresql-16-datasketches_1.7.0-1PIGSTY~noble_amd64.deb
postgresql-16-datasketches 1.7.0 u24.aarch64 pigsty 991.2 KiB postgresql-16-datasketches_1.7.0-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
datasketches_15 1.7.0 el8.x86_64 pigsty 342.1 KiB datasketches_15-1.7.0-1PIGSTY.el8.x86_64.rpm
datasketches_15 1.7.0 el8.aarch64 pigsty 332.3 KiB datasketches_15-1.7.0-1PIGSTY.el8.aarch64.rpm
datasketches_15 1.7.0 el9.x86_64 pigsty 323.5 KiB datasketches_15-1.7.0-1PIGSTY.el9.x86_64.rpm
datasketches_15 1.7.0 el9.aarch64 pigsty 329.1 KiB datasketches_15-1.7.0-1PIGSTY.el9.aarch64.rpm
datasketches_15 1.7.0 el10.x86_64 pigsty 325.9 KiB datasketches_15-1.7.0-1PIGSTY.el10.x86_64.rpm
datasketches_15 1.7.0 el10.aarch64 pigsty 325.2 KiB datasketches_15-1.7.0-1PIGSTY.el10.aarch64.rpm
postgresql-15-datasketches 1.7.0 d12.x86_64 pigsty 932.6 KiB postgresql-15-datasketches_1.7.0-1PIGSTY~bookworm_amd64.deb
postgresql-15-datasketches 1.7.0 d12.aarch64 pigsty 933.7 KiB postgresql-15-datasketches_1.7.0-1PIGSTY~bookworm_arm64.deb
postgresql-15-datasketches 1.7.0 d13.x86_64 pigsty 957.8 KiB postgresql-15-datasketches_1.7.0-1PIGSTY~trixie_amd64.deb
postgresql-15-datasketches 1.7.0 d13.aarch64 pigsty 957.9 KiB postgresql-15-datasketches_1.7.0-1PIGSTY~trixie_arm64.deb
postgresql-15-datasketches 1.7.0 u22.x86_64 pigsty 1.1 MiB postgresql-15-datasketches_1.7.0-1PIGSTY~jammy_amd64.deb
postgresql-15-datasketches 1.7.0 u22.aarch64 pigsty 1.1 MiB postgresql-15-datasketches_1.7.0-1PIGSTY~jammy_arm64.deb
postgresql-15-datasketches 1.7.0 u24.x86_64 pigsty 984.6 KiB postgresql-15-datasketches_1.7.0-1PIGSTY~noble_amd64.deb
postgresql-15-datasketches 1.7.0 u24.aarch64 pigsty 998.8 KiB postgresql-15-datasketches_1.7.0-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
datasketches_14 1.7.0 el8.x86_64 pigsty 342.1 KiB datasketches_14-1.7.0-1PIGSTY.el8.x86_64.rpm
datasketches_14 1.7.0 el8.aarch64 pigsty 332.3 KiB datasketches_14-1.7.0-1PIGSTY.el8.aarch64.rpm
datasketches_14 1.7.0 el9.x86_64 pigsty 323.9 KiB datasketches_14-1.7.0-1PIGSTY.el9.x86_64.rpm
datasketches_14 1.7.0 el9.aarch64 pigsty 328.8 KiB datasketches_14-1.7.0-1PIGSTY.el9.aarch64.rpm
datasketches_14 1.7.0 el10.x86_64 pigsty 325.9 KiB datasketches_14-1.7.0-1PIGSTY.el10.x86_64.rpm
datasketches_14 1.7.0 el10.aarch64 pigsty 325.2 KiB datasketches_14-1.7.0-1PIGSTY.el10.aarch64.rpm
postgresql-14-datasketches 1.7.0 d12.x86_64 pigsty 932.6 KiB postgresql-14-datasketches_1.7.0-1PIGSTY~bookworm_amd64.deb
postgresql-14-datasketches 1.7.0 d12.aarch64 pigsty 933.4 KiB postgresql-14-datasketches_1.7.0-1PIGSTY~bookworm_arm64.deb
postgresql-14-datasketches 1.7.0 d13.x86_64 pigsty 957.3 KiB postgresql-14-datasketches_1.7.0-1PIGSTY~trixie_amd64.deb
postgresql-14-datasketches 1.7.0 d13.aarch64 pigsty 957.5 KiB postgresql-14-datasketches_1.7.0-1PIGSTY~trixie_arm64.deb
postgresql-14-datasketches 1.7.0 u22.x86_64 pigsty 1.1 MiB postgresql-14-datasketches_1.7.0-1PIGSTY~jammy_amd64.deb
postgresql-14-datasketches 1.7.0 u22.aarch64 pigsty 1.1 MiB postgresql-14-datasketches_1.7.0-1PIGSTY~jammy_arm64.deb
postgresql-14-datasketches 1.7.0 u24.x86_64 pigsty 984.5 KiB postgresql-14-datasketches_1.7.0-1PIGSTY~noble_amd64.deb
postgresql-14-datasketches 1.7.0 u24.aarch64 pigsty 998.7 KiB postgresql-14-datasketches_1.7.0-1PIGSTY~noble_arm64.deb

Source

pig build pkg datasketches;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install datasketches;		# install via package name, for the active PG version

pig install datasketches -v 18;   # install for PG 18
pig install datasketches -v 17;   # install for PG 17
pig install datasketches -v 16;   # install for PG 16
pig install datasketches -v 15;   # install for PG 15
pig install datasketches -v 14;   # install for PG 14

Create this extension with:

CREATE EXTENSION datasketches;

Usage

Sources: README, Apache DataSketches site PostgreSQL extension for approximate analytics sketches and aggregates.

CREATE EXTENSION datasketches;

The extension supports CPC, HLL, Theta, Array Of Doubles, KLL, Quantiles, and Frequent Strings sketches.

Sketch Families

  • CPC for compact distinct counting.
  • HLL for HyperLogLog-style distinct counting.
  • Theta for distinct counting with set operations such as union, intersection, and A-not-B.
  • Array Of Doubles for tuple sketches with arrays of double values per key.
  • KLL for quantiles, ranks, PMF, and CDF estimation.
  • Quantiles sketch for long-term support of distribution estimates.
  • Frequent strings for tracking the heaviest items by count or weight.

Examples

SELECT cpc_sketch_to_string(cpc_sketch_build(1));
SELECT cpc_sketch_distinct(id) FROM random_ints_100m;
SELECT cpc_sketch_get_estimate(cpc_sketch_union(sketch)) FROM cpc_sketch_test;
SELECT theta_sketch_get_estimate(theta_sketch_union(sketch)) FROM theta_sketch_test;
SELECT theta_sketch_get_estimate(theta_sketch_intersection(sketch1, sketch2)) FROM theta_set_op_test;
SELECT hll_sketch_get_estimate(hll_sketch_union(sketch)) FROM hll_sketch_test;
SELECT hll_sketch_get_estimate(hll_sketch_union(hll_sketch_build(1), hll_sketch_build(2)));
SELECT kll_float_sketch_get_quantile(kll_float_sketch_merge(sketch), 0.5) FROM kll_float_sketch_test;
SELECT frequent_strings_sketch_result_no_false_negatives(frequent_strings_sketch_build(9, value), 1000000) FROM zipf_1p1_8k_100m;

Core Operations

  • Build sketches with *_sketch_build(...).
  • Merge or aggregate them with *_sketch_union(...), *_sketch_merge(...), and sketch-specific set-operation helpers.
  • Read estimates with *_sketch_get_estimate(...) and distribution helpers such as kll_float_sketch_get_quantile(...).

Notes

  • The README says the extension targets PostgreSQL 9.6 and higher and depends on Boost 1.75 and DataSketches C++ core 5.0.0 or later.
  • The upstream examples emphasize additive analytics in data cubes, not exact replacement for normal aggregates.
Last updated on