omnisketch
omnisketch
omnisketch : data structure for on-line agg of data into approximate sketch
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 4640 | omnisketch | omnisketch | 1.0.2 | FUNC | PostgreSQL | C |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
--s-d-r | No | Yes | No | Yes | yes | no |
| Relationships | |
|---|---|
| See Also | ddsketch hll count_distinct topn quantile lower_quantile first_last_agg |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY | 1.0.2 | 18 17 16 15 14 | omnisketch | - |
| RPM | PIGSTY | 1.0.2 | 18 17 16 15 14 | omnisketch_$v | - |
| DEB | PIGSTY | 1.0.2 | 18 17 16 15 14 | postgresql-$v-omnisketch | - |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
el8.x86_64 | PIGSTY 1.0.2 | PIGSTY 1.0.2 | PIGSTY 1.0.2 | PIGSTY 1.0.2 | PIGSTY 1.0.2 |
el8.aarch64 | PIGSTY 1.0.2 | PIGSTY 1.0.2 | PIGSTY 1.0.2 | PIGSTY 1.0.2 | PIGSTY 1.0.2 |
el9.x86_64 | PIGSTY 1.0.2 | PIGSTY 1.0.2 | PIGSTY 1.0.2 | PIGSTY 1.0.2 | PIGSTY 1.0.2 |
el9.aarch64 | PIGSTY 1.0.2 | PIGSTY 1.0.2 | PIGSTY 1.0.2 | PIGSTY 1.0.2 | PIGSTY 1.0.2 |
el10.x86_64 | PIGSTY 1.0.2 | PIGSTY 1.0.2 | PIGSTY 1.0.2 | PIGSTY 1.0.2 | PIGSTY 1.0.2 |
el10.aarch64 | PIGSTY 1.0.2 | PIGSTY 1.0.2 | PIGSTY 1.0.2 | PIGSTY 1.0.2 | PIGSTY 1.0.2 |
d12.x86_64 | PIGSTY 1.0.2 | PIGSTY 1.0.2 | PIGSTY 1.0.2 | PIGSTY 1.0.2 | PIGSTY 1.0.2 |
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 |
Source
pig build pkg omnisketch; # build rpm/debInstall
Make sure PGDG and PIGSTY repo available:
pig repo add pgsql -u # add both repo and update cacheInstall this extension with pig:
pig install omnisketch; # install via package name, for the active PG version
pig install omnisketch -v 18; # install for PG 18
pig install omnisketch -v 17; # install for PG 17
pig install omnisketch -v 16; # install for PG 16
pig install omnisketch -v 15; # install for PG 15
pig install omnisketch -v 14; # install for PG 14Create this extension with:
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;Last updated on