omnisketch
data structure for on-line agg of data into approximate sketch
Repository
tvondra/omnisketch
https://github.com/tvondra/omnisketch
Source
omnisketch-1.0.2.tar.gz
omnisketch-1.0.2.tar.gz
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
omnisketch | 1.0.2 | FUNC | PostgreSQL | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 4640 | omnisketch | No | Yes | No | Yes | No | Yes | - |
| Related | ddsketch hll count_distinct topn quantile lower_quantile first_last_agg |
|---|
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 1.0.2 | 1817161514 | omnisketch | - |
| RPM | PIGSTY | 1.0.2 | 1817161514 | omnisketch_$v | - |
| DEB | PIGSTY | 1.0.2 | 1817161514 | postgresql-$v-omnisketch | - |
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
| Function | Description |
|---|---|
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;
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.