omnisketch

data structure for on-line agg of data into approximate sketch

Overview

PackageVersionCategoryLicenseLanguage
omnisketch1.0.2FUNCPostgreSQLC
IDExtensionBinLibLoadCreateTrustRelocSchema
4640omnisketchNoYesNoYesNoYes-
Relatedddsketch hll count_distinct topn quantile lower_quantile first_last_agg

Version

TypeRepoVersionPG VerPackageDeps
EXTPIGSTY1.0.21817161514omnisketch-
RPMPIGSTY1.0.21817161514omnisketch_$v-
DEBPIGSTY1.0.21817161514postgresql-$v-omnisketch-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
el8.aarch64
el9.x86_64
el9.aarch64
el10.x86_64
el10.aarch64
d12.x86_64
d12.aarch64
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
d13.x86_64
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
d13.aarch64
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
u22.x86_64
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
u22.aarch64
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
u24.x86_64
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
u24.aarch64
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2

Build

You can build the RPM / DEB packages for omnisketch using pig build:

pig build pkg omnisketch         # build RPM / DEB packages

Install

You can install omnisketch directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:

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

Install the extension using pig or apt/yum/dnf:

pig install omnisketch;          # Install for current active PG version
pig ext install -y omnisketch -v 18  # PG 18
pig ext install -y omnisketch -v 17  # PG 17
pig ext install -y omnisketch -v 16  # PG 16
pig ext install -y omnisketch -v 15  # PG 15
pig ext install -y omnisketch -v 14  # PG 14
dnf install -y omnisketch_18       # PG 18
dnf install -y omnisketch_17       # PG 17
dnf install -y omnisketch_16       # PG 16
dnf install -y omnisketch_15       # PG 15
dnf install -y omnisketch_14       # PG 14
apt install -y postgresql-18-omnisketch   # PG 18
apt install -y postgresql-17-omnisketch   # PG 17
apt install -y postgresql-16-omnisketch   # PG 16
apt install -y postgresql-15-omnisketch   # PG 15
apt install -y postgresql-14-omnisketch   # PG 14

Create Extension:

CREATE EXTENSION omnisketch;

Usage

omnisketch: OmniSketch data structure for multi-dimensional stream analytics

Implements OmniSketch for on-line aggregation into approximate sketches and answering count queries with arbitrary predicates on multi-dimensional data.

CREATE EXTENSION omnisketch;

Functions

FunctionDescription
omnisketch(epsilon, delta, record)Build a sketch from data with accuracy parameters
omnisketch(sketch)Combine multiple compatible sketches
omnisketch_count(sketch)Return total records added to the sketch
omnisketch_estimate(sketch, record)Estimate count of records matching predicates

Parameters

  • epsilon – accuracy relative to total records, range [0,1] (lower = more accurate, larger sketch)
  • delta – accuracy, range [0,1]

Examples

-- Create sample data
CREATE TABLE data (id INT, a INT, b INT);
INSERT INTO data SELECT i, mod(i,100), mod(i,100) FROM generate_series(1,1000000) s(i);

-- Pre-calculate sketches on partitions
CREATE TABLE sketches AS
SELECT mod(id,10) AS p, omnisketch(0.01, 0.01, (a, b)) AS s
FROM data GROUP BY mod(id,10);

-- Estimate count for condition (a = 10 AND b = 10)
SELECT omnisketch_estimate(omnisketch(s), (10, 10)) FROM sketches;

-- Get total record count
SELECT omnisketch_count(omnisketch(s)) FROM sketches;

Last Modified 2026-03-12: add pg extension catalog (95749bf)