Skip to content

pg_accumulator

Accumulation registers for balance and turnover tracking in PostgreSQL

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.2.0 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 currency financial omni_ledger

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT PIGSTY 1.2.0 19 18 17 16 15 pg_accumulator plpgsql
RPM PIGSTY 1.2.0 19 18 17 16 15 pg_accumulator_$v -
DEB PIGSTY 1.2.0 19 18 17 16 15 postgresql-$v-pg-accumulator -
Linux / PG PG19 PG18 PG17 PG16 PG15
el8.x86_64 N/A PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0
el8.aarch64 N/A PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0
el9.x86_64 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0
el9.aarch64 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0
el10.x86_64 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0
el10.aarch64 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0
d12.x86_64 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0
d12.aarch64 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0
d13.x86_64 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0
d13.aarch64 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0
u22.x86_64 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0
u22.aarch64 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0
u24.x86_64 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0
u24.aarch64 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0
u26.x86_64 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0
u26.aarch64 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0 PIGSTY 1.2.0
Package Version OS ORG SIZE File URL
pg_accumulator_19 1.2.0 el9.x86_64 pigsty 72.9 KiB pg_accumulator_19-1.2.0-1PGSTY.el9.x86_64.rpm
pg_accumulator_19 1.2.0 el9.aarch64 pigsty 72.5 KiB pg_accumulator_19-1.2.0-1PGSTY.el9.aarch64.rpm
pg_accumulator_19 1.2.0 el10.x86_64 pigsty 73.2 KiB pg_accumulator_19-1.2.0-1PGSTY.el10.x86_64.rpm
pg_accumulator_19 1.2.0 el10.aarch64 pigsty 72.9 KiB pg_accumulator_19-1.2.0-1PGSTY.el10.aarch64.rpm
postgresql-19-pg-accumulator 1.2.0 d12.x86_64 pigsty 54.9 KiB postgresql-19-pg-accumulator_1.2.0-1PGSTY~bookworm_amd64.deb
postgresql-19-pg-accumulator 1.2.0 d12.aarch64 pigsty 54.8 KiB postgresql-19-pg-accumulator_1.2.0-1PGSTY~bookworm_arm64.deb
postgresql-19-pg-accumulator 1.2.0 d13.x86_64 pigsty 55.0 KiB postgresql-19-pg-accumulator_1.2.0-1PGSTY~trixie_amd64.deb
postgresql-19-pg-accumulator 1.2.0 d13.aarch64 pigsty 54.8 KiB postgresql-19-pg-accumulator_1.2.0-1PGSTY~trixie_arm64.deb
postgresql-19-pg-accumulator 1.2.0 u22.x86_64 pigsty 56.4 KiB postgresql-19-pg-accumulator_1.2.0-1PGSTY~jammy_amd64.deb
postgresql-19-pg-accumulator 1.2.0 u22.aarch64 pigsty 56.3 KiB postgresql-19-pg-accumulator_1.2.0-1PGSTY~jammy_arm64.deb
postgresql-19-pg-accumulator 1.2.0 u24.x86_64 pigsty 56.2 KiB postgresql-19-pg-accumulator_1.2.0-1PGSTY~noble_amd64.deb
postgresql-19-pg-accumulator 1.2.0 u24.aarch64 pigsty 55.9 KiB postgresql-19-pg-accumulator_1.2.0-1PGSTY~noble_arm64.deb
postgresql-19-pg-accumulator 1.2.0 u26.x86_64 pigsty 56.0 KiB postgresql-19-pg-accumulator_1.2.0-1PGSTY~resolute_amd64.deb
postgresql-19-pg-accumulator 1.2.0 u26.aarch64 pigsty 55.8 KiB postgresql-19-pg-accumulator_1.2.0-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_accumulator_18 1.2.0 el8.x86_64 pigsty 75.1 KiB pg_accumulator_18-1.2.0-1PGSTY.el8.x86_64.rpm
pg_accumulator_18 1.2.0 el8.aarch64 pigsty 74.8 KiB pg_accumulator_18-1.2.0-1PGSTY.el8.aarch64.rpm
pg_accumulator_18 1.2.0 el9.x86_64 pigsty 73.2 KiB pg_accumulator_18-1.2.0-1PGSTY.el9.x86_64.rpm
pg_accumulator_18 1.2.0 el9.aarch64 pigsty 72.5 KiB pg_accumulator_18-1.2.0-1PGSTY.el9.aarch64.rpm
pg_accumulator_18 1.2.0 el10.x86_64 pigsty 73.3 KiB pg_accumulator_18-1.2.0-1PGSTY.el10.x86_64.rpm
pg_accumulator_18 1.2.0 el10.aarch64 pigsty 72.9 KiB pg_accumulator_18-1.2.0-1PGSTY.el10.aarch64.rpm
postgresql-18-pg-accumulator 1.2.0 d12.x86_64 pigsty 54.9 KiB postgresql-18-pg-accumulator_1.2.0-1PGSTY~bookworm_amd64.deb
postgresql-18-pg-accumulator 1.2.0 d12.aarch64 pigsty 54.6 KiB postgresql-18-pg-accumulator_1.2.0-1PGSTY~bookworm_arm64.deb
postgresql-18-pg-accumulator 1.2.0 d13.x86_64 pigsty 54.9 KiB postgresql-18-pg-accumulator_1.2.0-1PGSTY~trixie_amd64.deb
postgresql-18-pg-accumulator 1.2.0 d13.aarch64 pigsty 54.7 KiB postgresql-18-pg-accumulator_1.2.0-1PGSTY~trixie_arm64.deb
postgresql-18-pg-accumulator 1.2.0 u22.x86_64 pigsty 56.5 KiB postgresql-18-pg-accumulator_1.2.0-1PGSTY~jammy_amd64.deb
postgresql-18-pg-accumulator 1.2.0 u22.aarch64 pigsty 56.3 KiB postgresql-18-pg-accumulator_1.2.0-1PGSTY~jammy_arm64.deb
postgresql-18-pg-accumulator 1.2.0 u24.x86_64 pigsty 56.0 KiB postgresql-18-pg-accumulator_1.2.0-1PGSTY~noble_amd64.deb
postgresql-18-pg-accumulator 1.2.0 u24.aarch64 pigsty 55.7 KiB postgresql-18-pg-accumulator_1.2.0-1PGSTY~noble_arm64.deb
postgresql-18-pg-accumulator 1.2.0 u26.x86_64 pigsty 56.1 KiB postgresql-18-pg-accumulator_1.2.0-1PGSTY~resolute_amd64.deb
postgresql-18-pg-accumulator 1.2.0 u26.aarch64 pigsty 55.8 KiB postgresql-18-pg-accumulator_1.2.0-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_accumulator_17 1.2.0 el8.x86_64 pigsty 75.1 KiB pg_accumulator_17-1.2.0-1PGSTY.el8.x86_64.rpm
pg_accumulator_17 1.2.0 el8.aarch64 pigsty 74.8 KiB pg_accumulator_17-1.2.0-1PGSTY.el8.aarch64.rpm
pg_accumulator_17 1.2.0 el9.x86_64 pigsty 73.2 KiB pg_accumulator_17-1.2.0-1PGSTY.el9.x86_64.rpm
pg_accumulator_17 1.2.0 el9.aarch64 pigsty 72.4 KiB pg_accumulator_17-1.2.0-1PGSTY.el9.aarch64.rpm
pg_accumulator_17 1.2.0 el10.x86_64 pigsty 73.3 KiB pg_accumulator_17-1.2.0-1PGSTY.el10.x86_64.rpm
pg_accumulator_17 1.2.0 el10.aarch64 pigsty 72.8 KiB pg_accumulator_17-1.2.0-1PGSTY.el10.aarch64.rpm
postgresql-17-pg-accumulator 1.2.0 d12.x86_64 pigsty 54.8 KiB postgresql-17-pg-accumulator_1.2.0-1PGSTY~bookworm_amd64.deb
postgresql-17-pg-accumulator 1.2.0 d12.aarch64 pigsty 54.6 KiB postgresql-17-pg-accumulator_1.2.0-1PGSTY~bookworm_arm64.deb
postgresql-17-pg-accumulator 1.2.0 d13.x86_64 pigsty 54.8 KiB postgresql-17-pg-accumulator_1.2.0-1PGSTY~trixie_amd64.deb
postgresql-17-pg-accumulator 1.2.0 d13.aarch64 pigsty 54.7 KiB postgresql-17-pg-accumulator_1.2.0-1PGSTY~trixie_arm64.deb
postgresql-17-pg-accumulator 1.2.0 u22.x86_64 pigsty 57.8 KiB postgresql-17-pg-accumulator_1.2.0-1PGSTY~jammy_amd64.deb
postgresql-17-pg-accumulator 1.2.0 u22.aarch64 pigsty 57.5 KiB postgresql-17-pg-accumulator_1.2.0-1PGSTY~jammy_arm64.deb
postgresql-17-pg-accumulator 1.2.0 u24.x86_64 pigsty 56.0 KiB postgresql-17-pg-accumulator_1.2.0-1PGSTY~noble_amd64.deb
postgresql-17-pg-accumulator 1.2.0 u24.aarch64 pigsty 55.7 KiB postgresql-17-pg-accumulator_1.2.0-1PGSTY~noble_arm64.deb
postgresql-17-pg-accumulator 1.2.0 u26.x86_64 pigsty 56.1 KiB postgresql-17-pg-accumulator_1.2.0-1PGSTY~resolute_amd64.deb
postgresql-17-pg-accumulator 1.2.0 u26.aarch64 pigsty 55.8 KiB postgresql-17-pg-accumulator_1.2.0-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_accumulator_16 1.2.0 el8.x86_64 pigsty 75.1 KiB pg_accumulator_16-1.2.0-1PGSTY.el8.x86_64.rpm
pg_accumulator_16 1.2.0 el8.aarch64 pigsty 74.8 KiB pg_accumulator_16-1.2.0-1PGSTY.el8.aarch64.rpm
pg_accumulator_16 1.2.0 el9.x86_64 pigsty 73.2 KiB pg_accumulator_16-1.2.0-1PGSTY.el9.x86_64.rpm
pg_accumulator_16 1.2.0 el9.aarch64 pigsty 72.5 KiB pg_accumulator_16-1.2.0-1PGSTY.el9.aarch64.rpm
pg_accumulator_16 1.2.0 el10.x86_64 pigsty 73.3 KiB pg_accumulator_16-1.2.0-1PGSTY.el10.x86_64.rpm
pg_accumulator_16 1.2.0 el10.aarch64 pigsty 72.8 KiB pg_accumulator_16-1.2.0-1PGSTY.el10.aarch64.rpm
postgresql-16-pg-accumulator 1.2.0 d12.x86_64 pigsty 54.8 KiB postgresql-16-pg-accumulator_1.2.0-1PGSTY~bookworm_amd64.deb
postgresql-16-pg-accumulator 1.2.0 d12.aarch64 pigsty 54.6 KiB postgresql-16-pg-accumulator_1.2.0-1PGSTY~bookworm_arm64.deb
postgresql-16-pg-accumulator 1.2.0 d13.x86_64 pigsty 54.8 KiB postgresql-16-pg-accumulator_1.2.0-1PGSTY~trixie_amd64.deb
postgresql-16-pg-accumulator 1.2.0 d13.aarch64 pigsty 54.7 KiB postgresql-16-pg-accumulator_1.2.0-1PGSTY~trixie_arm64.deb
postgresql-16-pg-accumulator 1.2.0 u22.x86_64 pigsty 57.8 KiB postgresql-16-pg-accumulator_1.2.0-1PGSTY~jammy_amd64.deb
postgresql-16-pg-accumulator 1.2.0 u22.aarch64 pigsty 57.5 KiB postgresql-16-pg-accumulator_1.2.0-1PGSTY~jammy_arm64.deb
postgresql-16-pg-accumulator 1.2.0 u24.x86_64 pigsty 56.0 KiB postgresql-16-pg-accumulator_1.2.0-1PGSTY~noble_amd64.deb
postgresql-16-pg-accumulator 1.2.0 u24.aarch64 pigsty 55.9 KiB postgresql-16-pg-accumulator_1.2.0-1PGSTY~noble_arm64.deb
postgresql-16-pg-accumulator 1.2.0 u26.x86_64 pigsty 56.1 KiB postgresql-16-pg-accumulator_1.2.0-1PGSTY~resolute_amd64.deb
postgresql-16-pg-accumulator 1.2.0 u26.aarch64 pigsty 55.8 KiB postgresql-16-pg-accumulator_1.2.0-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_accumulator_15 1.2.0 el8.x86_64 pigsty 75.2 KiB pg_accumulator_15-1.2.0-1PGSTY.el8.x86_64.rpm
pg_accumulator_15 1.2.0 el8.aarch64 pigsty 74.9 KiB pg_accumulator_15-1.2.0-1PGSTY.el8.aarch64.rpm
pg_accumulator_15 1.2.0 el9.x86_64 pigsty 73.3 KiB pg_accumulator_15-1.2.0-1PGSTY.el9.x86_64.rpm
pg_accumulator_15 1.2.0 el9.aarch64 pigsty 72.6 KiB pg_accumulator_15-1.2.0-1PGSTY.el9.aarch64.rpm
pg_accumulator_15 1.2.0 el10.x86_64 pigsty 73.4 KiB pg_accumulator_15-1.2.0-1PGSTY.el10.x86_64.rpm
pg_accumulator_15 1.2.0 el10.aarch64 pigsty 73.0 KiB pg_accumulator_15-1.2.0-1PGSTY.el10.aarch64.rpm
postgresql-15-pg-accumulator 1.2.0 d12.x86_64 pigsty 54.9 KiB postgresql-15-pg-accumulator_1.2.0-1PGSTY~bookworm_amd64.deb
postgresql-15-pg-accumulator 1.2.0 d12.aarch64 pigsty 55.8 KiB postgresql-15-pg-accumulator_1.2.0-1PGSTY~bookworm_arm64.deb
postgresql-15-pg-accumulator 1.2.0 d13.x86_64 pigsty 54.9 KiB postgresql-15-pg-accumulator_1.2.0-1PGSTY~trixie_amd64.deb
postgresql-15-pg-accumulator 1.2.0 d13.aarch64 pigsty 54.7 KiB postgresql-15-pg-accumulator_1.2.0-1PGSTY~trixie_arm64.deb
postgresql-15-pg-accumulator 1.2.0 u22.x86_64 pigsty 57.9 KiB postgresql-15-pg-accumulator_1.2.0-1PGSTY~jammy_amd64.deb
postgresql-15-pg-accumulator 1.2.0 u22.aarch64 pigsty 57.6 KiB postgresql-15-pg-accumulator_1.2.0-1PGSTY~jammy_arm64.deb
postgresql-15-pg-accumulator 1.2.0 u24.x86_64 pigsty 56.2 KiB postgresql-15-pg-accumulator_1.2.0-1PGSTY~noble_amd64.deb
postgresql-15-pg-accumulator 1.2.0 u24.aarch64 pigsty 55.8 KiB postgresql-15-pg-accumulator_1.2.0-1PGSTY~noble_arm64.deb
postgresql-15-pg-accumulator 1.2.0 u26.x86_64 pigsty 56.2 KiB postgresql-15-pg-accumulator_1.2.0-1PGSTY~resolute_amd64.deb
postgresql-15-pg-accumulator 1.2.0 u26.aarch64 pigsty 56.0 KiB postgresql-15-pg-accumulator_1.2.0-1PGSTY~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 19;   # install for PG 19
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

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.

Table reader