Skip to content
pg_accumulator

pg_accumulator

pg_accumulator : Accumulation registers for balance and turnover tracking in PostgreSQL

Overview

ID Extension Package Version Category License Language
4845
pg_accumulator
pg_accumulator
1.1.3
FUNC
PostgreSQL
C
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--s-d--
No
Yes
No
Yes
no
no
Relationships
Schemas accum
Requires
plpgsql
See Also
financial
topn
quantile
first_last_agg

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT
PIGSTY
1.1.3
18
17
16
15
14
pg_accumulator plpgsql
RPM
PIGSTY
1.1.3
18
17
16
15
14
pg_accumulator_$v -
DEB
PIGSTY
1.1.3
18
17
16
15
14
postgresql-$v-pg-accumulator -
Linux / PG PG18 PG17 PG16 PG15 PG14
el8.x86_64
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
el8.aarch64
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
el9.x86_64
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
el9.aarch64
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
el10.x86_64
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
el10.aarch64
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
d12.x86_64
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
d12.aarch64
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
d13.x86_64
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
d13.aarch64
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
u22.x86_64
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
u22.aarch64
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
u24.x86_64
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
u24.aarch64
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
u26.x86_64
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
u26.aarch64
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
PIGSTY 1.1.3
Package Version OS ORG SIZE File URL
pg_accumulator_18 1.1.3 el8.x86_64 pigsty 56.6 KiB pg_accumulator_18-1.1.3-1PIGSTY.el8.x86_64.rpm
pg_accumulator_18 1.1.3 el8.aarch64 pigsty 56.8 KiB pg_accumulator_18-1.1.3-1PIGSTY.el8.aarch64.rpm
pg_accumulator_18 1.1.3 el9.x86_64 pigsty 54.3 KiB pg_accumulator_18-1.1.3-1PIGSTY.el9.x86_64.rpm
pg_accumulator_18 1.1.3 el9.aarch64 pigsty 54.2 KiB pg_accumulator_18-1.1.3-1PIGSTY.el9.aarch64.rpm
pg_accumulator_18 1.1.3 el10.x86_64 pigsty 54.3 KiB pg_accumulator_18-1.1.3-1PIGSTY.el10.x86_64.rpm
pg_accumulator_18 1.1.3 el10.aarch64 pigsty 54.5 KiB pg_accumulator_18-1.1.3-1PIGSTY.el10.aarch64.rpm
postgresql-18-pg-accumulator 1.1.3 d12.x86_64 pigsty 51.1 KiB postgresql-18-pg-accumulator_1.1.3-1PIGSTY~bookworm_amd64.deb
postgresql-18-pg-accumulator 1.1.3 d12.aarch64 pigsty 50.9 KiB postgresql-18-pg-accumulator_1.1.3-1PIGSTY~bookworm_arm64.deb
postgresql-18-pg-accumulator 1.1.3 d13.x86_64 pigsty 51.2 KiB postgresql-18-pg-accumulator_1.1.3-1PIGSTY~trixie_amd64.deb
postgresql-18-pg-accumulator 1.1.3 d13.aarch64 pigsty 50.9 KiB postgresql-18-pg-accumulator_1.1.3-1PIGSTY~trixie_arm64.deb
postgresql-18-pg-accumulator 1.1.3 u22.x86_64 pigsty 52.8 KiB postgresql-18-pg-accumulator_1.1.3-1PIGSTY~jammy_amd64.deb
postgresql-18-pg-accumulator 1.1.3 u22.aarch64 pigsty 52.5 KiB postgresql-18-pg-accumulator_1.1.3-1PIGSTY~jammy_arm64.deb
postgresql-18-pg-accumulator 1.1.3 u24.x86_64 pigsty 52.2 KiB postgresql-18-pg-accumulator_1.1.3-1PIGSTY~noble_amd64.deb
postgresql-18-pg-accumulator 1.1.3 u24.aarch64 pigsty 51.9 KiB postgresql-18-pg-accumulator_1.1.3-1PIGSTY~noble_arm64.deb
postgresql-18-pg-accumulator 1.1.3 u26.x86_64 pigsty 52.3 KiB postgresql-18-pg-accumulator_1.1.3-1PIGSTY~resolute_amd64.deb
postgresql-18-pg-accumulator 1.1.3 u26.aarch64 pigsty 52.1 KiB postgresql-18-pg-accumulator_1.1.3-1PIGSTY~resolute_arm64.deb

Source

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

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

Create this extension with:

CREATE EXTENSION pg_accumulator CASCADE; -- requires plpgsql

Usage

Sources: README, documentation, control file

pg_accumulator implements declarative accumulation registers for PostgreSQL. A register records movements across arbitrary dimensions and resources, then exposes generated functions for balances, turnovers, movement history, verification, and rebuild operations.

Enable

CREATE EXTENSION pg_accumulator;

For high-write workloads that use the delta buffer and background worker, preload the library and restart PostgreSQL:

shared_preload_libraries = 'pg_accumulator'

Create A Register

SELECT accum.register_create(
  name := 'inventory',
  dimensions := '{"warehouse": "int", "product": "int"}',
  resources := '{"quantity": "numeric", "amount": "numeric"}',
  kind := 'balance'
);

The call creates the register metadata, movement table, total tables, balance cache, triggers, generated query functions, and supporting indexes.

Post And Query Movements

SELECT accum.register_post('inventory', '{
  "period": "2026-04-01",
  "document": "receipt:1",
  "dimensions": {"warehouse": 1, "product": 42},
  "resources": {"quantity": 10, "amount": 250}
}');

SELECT * FROM accum.inventory_balance(
  dimensions := '{"warehouse": 1, "product": 42}'
);

SELECT * FROM accum.inventory_turnover(
  from_date := '2026-04-01',
  to_date := '2026-04-30',
  dimensions := '{"warehouse": 1}',
  group_by := '["product"]'
);

Corrections And Maintenance

Use register_unpost and register_repost for retroactive corrections. Use register_verify, register_rebuild_totals, and register_rebuild_cache to check and repair derived state when needed.

SELECT accum.register_unpost('inventory', 'receipt:1');
SELECT accum.register_verify('inventory');

Configuration

The documented GUCs include pg_accumulator.background_workers, pg_accumulator.delta_merge_interval, pg_accumulator.delta_merge_delay, pg_accumulator.delta_merge_batch_size, pg_accumulator.partitions_ahead, and pg_accumulator.maintenance_interval.

Last updated on