Skip to content
pgfaceting

pgfaceting

pgfaceting : fast faceting queries using an inverted index

Overview

ID Extension Package Version Category License Language
3640
pgfaceting
pgfaceting
0.2.0
TYPE
BSD-3-Clause
SQL
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
----d--
No
No
No
Yes
no
no
Relationships
Schemas faceting
Requires
roaringbitmap
See Also
pg_search
pgroonga
roaringbitmap
rum
hll
bloom
pg_tokenizer
pg_textsearch
pg_fts
vchord_bm25

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT
MIXED
0.2.0
18
17
16
15
14
pgfaceting roaringbitmap
RPM
PIGSTY
0.2.0
18
17
16
15
14
pgfaceting_$v -
DEB
PGDG
0.2.0
18
17
16
15
14
postgresql-$v-pgfaceting -
Linux / PG PG18 PG17 PG16 PG15 PG14
el8.x86_64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
el8.aarch64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
el9.x86_64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
el9.aarch64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
el10.x86_64
PGDG 0.2.0
PGDG 0.2.0
PGDG 0.2.0
PGDG 0.2.0
PGDG 0.2.0
el10.aarch64
PGDG 0.2.0
PGDG 0.2.0
PGDG 0.2.0
PGDG 0.2.0
PGDG 0.2.0
d12.x86_64
PGDG 0.2.0
PGDG 0.2.0
PGDG 0.2.0
PGDG 0.2.0
PGDG 0.2.0
d12.aarch64
PGDG 0.2.0
PGDG 0.2.0
PGDG 0.2.0
PGDG 0.2.0
PGDG 0.2.0
d13.x86_64
PGDG 0.2.0
PGDG 0.2.0
PGDG 0.2.0
PGDG 0.2.0
PGDG 0.2.0
d13.aarch64
PGDG 0.2.0
PGDG 0.2.0
PGDG 0.2.0
PGDG 0.2.0
PGDG 0.2.0
u22.x86_64
PGDG 0.2.0
PGDG 0.2.0
PGDG 0.2.0
PGDG 0.2.0
PGDG 0.2.0
u22.aarch64
PGDG 0.2.0
PGDG 0.2.0
PGDG 0.2.0
PGDG 0.2.0
PGDG 0.2.0
u24.x86_64
PGDG 0.2.0
PGDG 0.2.0
PGDG 0.2.0
PGDG 0.2.0
PGDG 0.2.0
u24.aarch64
PGDG 0.2.0
PGDG 0.2.0
PGDG 0.2.0
PGDG 0.2.0
PGDG 0.2.0
u26.x86_64
PGDG 0.2.0
PGDG 0.2.0
PGDG 0.2.0
PGDG 0.2.0
PGDG 0.2.0
u26.aarch64
PGDG 0.2.0
PGDG 0.2.0
PGDG 0.2.0
PGDG 0.2.0
PGDG 0.2.0
Package Version OS ORG SIZE File URL
pgfaceting_18 0.2.0 el8.x86_64 pigsty 14.6 KiB pgfaceting_18-0.2.0-1PIGSTY.el8.x86_64.rpm
pgfaceting_18 0.2.0 el8.x86_64 pgdg 15.5 KiB pgfaceting_18-0.2.0-1PGDG.rhel8.noarch.rpm
pgfaceting_18 0.2.0 el8.aarch64 pigsty 14.6 KiB pgfaceting_18-0.2.0-1PIGSTY.el8.aarch64.rpm
pgfaceting_18 0.2.0 el8.aarch64 pgdg 15.5 KiB pgfaceting_18-0.2.0-1PGDG.rhel8.noarch.rpm
pgfaceting_18 0.2.0 el9.x86_64 pigsty 14.4 KiB pgfaceting_18-0.2.0-1PIGSTY.el9.x86_64.rpm
pgfaceting_18 0.2.0 el9.x86_64 pgdg 15.3 KiB pgfaceting_18-0.2.0-1PGDG.rhel9.8.noarch.rpm
pgfaceting_18 0.2.0 el9.x86_64 pgdg 15.3 KiB pgfaceting_18-0.2.0-1PGDG.rhel9.noarch.rpm
pgfaceting_18 0.2.0 el9.aarch64 pigsty 14.4 KiB pgfaceting_18-0.2.0-1PIGSTY.el9.aarch64.rpm
pgfaceting_18 0.2.0 el9.aarch64 pgdg 15.3 KiB pgfaceting_18-0.2.0-1PGDG.rhel9.8.noarch.rpm
pgfaceting_18 0.2.0 el9.aarch64 pgdg 15.3 KiB pgfaceting_18-0.2.0-1PGDG.rhel9.noarch.rpm
pgfaceting_18 0.2.0 el10.x86_64 pgdg 15.5 KiB pgfaceting_18-0.2.0-1PGDG.rhel10.2.noarch.rpm
pgfaceting_18 0.2.0 el10.x86_64 pgdg 15.8 KiB pgfaceting_18-0.2.0-1PGDG.rhel10.noarch.rpm
pgfaceting_18 0.2.0 el10.aarch64 pgdg 15.4 KiB pgfaceting_18-0.2.0-1PGDG.rhel10.2.noarch.rpm
pgfaceting_18 0.2.0 el10.aarch64 pgdg 15.8 KiB pgfaceting_18-0.2.0-1PGDG.rhel10.noarch.rpm
postgresql-18-pgfaceting 0.2.0 d12.x86_64 pgdg 9.7 KiB postgresql-18-pgfaceting_0.2.0-5.pgdg12+1_all.deb
postgresql-18-pgfaceting 0.2.0 d12.aarch64 pgdg 9.7 KiB postgresql-18-pgfaceting_0.2.0-5.pgdg12+1_all.deb
postgresql-18-pgfaceting 0.2.0 d13.x86_64 pgdg 9.7 KiB postgresql-18-pgfaceting_0.2.0-5.pgdg13+1_all.deb
postgresql-18-pgfaceting 0.2.0 d13.aarch64 pgdg 9.7 KiB postgresql-18-pgfaceting_0.2.0-5.pgdg13+1_all.deb
postgresql-18-pgfaceting 0.2.0 u22.x86_64 pgdg 9.7 KiB postgresql-18-pgfaceting_0.2.0-5.pgdg22.04+1_all.deb
postgresql-18-pgfaceting 0.2.0 u22.aarch64 pgdg 9.7 KiB postgresql-18-pgfaceting_0.2.0-5.pgdg22.04+1_all.deb
postgresql-18-pgfaceting 0.2.0 u24.x86_64 pgdg 9.7 KiB postgresql-18-pgfaceting_0.2.0-5.pgdg24.04+1_all.deb
postgresql-18-pgfaceting 0.2.0 u24.aarch64 pgdg 9.7 KiB postgresql-18-pgfaceting_0.2.0-5.pgdg24.04+1_all.deb
postgresql-18-pgfaceting 0.2.0 u26.x86_64 pgdg 9.7 KiB postgresql-18-pgfaceting_0.2.0-5.pgdg26.04+1_all.deb
postgresql-18-pgfaceting 0.2.0 u26.aarch64 pgdg 9.7 KiB postgresql-18-pgfaceting_0.2.0-5.pgdg26.04+1_all.deb

Source

pig build pkg pgfaceting;		# build rpm

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 pgfaceting;		# install via package name, for the active PG version

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

Create this extension with:

CREATE EXTENSION pgfaceting CASCADE; -- requires roaringbitmap

Usage

pgfaceting: fast faceted search using inverted indexes with roaring bitmaps

The pgfaceting extension enables rapid facet counting via inverted indexes built with roaring bitmaps. Requires the pg_roaringbitmap extension.

CREATE EXTENSION pgfaceting;

Facet Types

  • plain_facet(column): Use column values directly as facets
  • datetrunc_facet(column, precision): Apply date truncation (e.g., monthly/yearly buckets)
  • bucket_facet(column, buckets): Assign continuous variables to predefined ranges

Key Functions

-- Create facet infrastructure for a table
SELECT pgfaceting.add_faceting_to_table(
    'products',
    'id',
    ARRAY[
        plain_facet('color'),
        plain_facet('size'),
        bucket_facet('price', ARRAY[0, 10, 50, 100, 500])
    ]
);

-- Run maintenance to merge incremental changes
SELECT pgfaceting.run_maintenance();

-- Merge deltas for a specific table
SELECT pgfaceting.merge_deltas('products');

-- Get top N facet values
SELECT pgfaceting.top_values('products', 10);

-- Count results with facet filters
SELECT pgfaceting.count_results('products', filters);

Architecture

The extension maintains two auxiliary tables per indexed table: a main facets table with roaring bitmaps mapping facet values to row IDs, and a delta table for incremental changes between maintenance runs.

Currently supports only 32-bit integer ID columns.

Last updated on