Skip to content

pg_ivm

pg_ivm : incremental view maintenance on PostgreSQL

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
2840
pg_ivm
pg_ivm
1.14
FEAT
PostgreSQL
C
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--sLd--
No
Yes
Yes
Yes
no
no
Relationships
Schemaspg_catalog
See Also
age
hll
rum
pg_graphql
pg_jsonschema
jsquery
pg_hint_plan

deb takeover by pgdg since 2026-01

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXT
MIXED
1.14
18
17
16
15
14
pg_ivm-
RPM
PIGSTY
1.14
18
17
16
15
14
pg_ivm_$v-
DEB
PIGSTY
1.14
18
17
16
15
14
postgresql-$v-pg-ivm-
Linux / PGPG18PG17PG16PG15PG14
el8.x86_64
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
el8.aarch64
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
el9.x86_64
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
el9.aarch64
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
el10.x86_64
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
el10.aarch64
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
d12.x86_64
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
d12.aarch64
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
d13.x86_64
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
d13.aarch64
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
u22.x86_64
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
u22.aarch64
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
u24.x86_64
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
u24.aarch64
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
u26.x86_64
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
u26.aarch64
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
PIGSTY 1.14
PackageVersionOSORGSIZEFile URL
pg_ivm_181.14el8.x86_64pigsty57.9 KiBpg_ivm_18-1.14-1PIGSTY.el8.x86_64.rpm
pg_ivm_181.14el8.x86_64pgdg50.3 KiBpg_ivm_18-1.14-1PGDG.rhel8.10.x86_64.rpm
pg_ivm_181.13el8.x86_64pgdg49.5 KiBpg_ivm_18-1.13-1PGDG.rhel8.x86_64.rpm
pg_ivm_181.12el8.x86_64pgdg43.3 KiBpg_ivm_18-1.12-1PGDG.rhel8.x86_64.rpm
pg_ivm_181.14el8.aarch64pigsty55.9 KiBpg_ivm_18-1.14-1PIGSTY.el8.aarch64.rpm
pg_ivm_181.14el8.aarch64pgdg48.1 KiBpg_ivm_18-1.14-1PGDG.rhel8.10.aarch64.rpm
pg_ivm_181.13el8.aarch64pgdg47.5 KiBpg_ivm_18-1.13-1PGDG.rhel8.aarch64.rpm
pg_ivm_181.12el8.aarch64pgdg41.2 KiBpg_ivm_18-1.12-1PGDG.rhel8.aarch64.rpm
pg_ivm_181.14el9.x86_64pigsty57.5 KiBpg_ivm_18-1.14-1PIGSTY.el9.x86_64.rpm
pg_ivm_181.14el9.x86_64pgdg49.7 KiBpg_ivm_18-1.14-1PGDG.rhel9.7.x86_64.rpm
pg_ivm_181.13el9.x86_64pgdg49.3 KiBpg_ivm_18-1.13-1PGDG.rhel9.x86_64.rpm
pg_ivm_181.12el9.x86_64pgdg43.3 KiBpg_ivm_18-1.12-1PGDG.rhel9.x86_64.rpm
pg_ivm_181.14el9.aarch64pigsty56.3 KiBpg_ivm_18-1.14-1PIGSTY.el9.aarch64.rpm
pg_ivm_181.14el9.aarch64pgdg48.3 KiBpg_ivm_18-1.14-1PGDG.rhel9.7.aarch64.rpm
pg_ivm_181.13el9.aarch64pgdg48.1 KiBpg_ivm_18-1.13-1PGDG.rhel9.aarch64.rpm
pg_ivm_181.12el9.aarch64pgdg42.0 KiBpg_ivm_18-1.12-1PGDG.rhel9.aarch64.rpm
pg_ivm_181.14el10.x86_64pigsty58.5 KiBpg_ivm_18-1.14-1PIGSTY.el10.x86_64.rpm
pg_ivm_181.14el10.x86_64pgdg50.8 KiBpg_ivm_18-1.14-1PGDG.rhel10.1.x86_64.rpm
pg_ivm_181.13el10.x86_64pgdg50.6 KiBpg_ivm_18-1.13-1PGDG.rhel10.x86_64.rpm
pg_ivm_181.12el10.x86_64pgdg44.1 KiBpg_ivm_18-1.12-1PGDG.rhel10.x86_64.rpm
pg_ivm_181.14el10.aarch64pigsty57.4 KiBpg_ivm_18-1.14-1PIGSTY.el10.aarch64.rpm
pg_ivm_181.14el10.aarch64pgdg49.5 KiBpg_ivm_18-1.14-1PGDG.rhel10.1.aarch64.rpm
pg_ivm_181.13el10.aarch64pgdg49.7 KiBpg_ivm_18-1.13-1PGDG.rhel10.aarch64.rpm
pg_ivm_181.12el10.aarch64pgdg42.8 KiBpg_ivm_18-1.12-1PGDG.rhel10.aarch64.rpm
postgresql-18-pg-ivm1.14d12.x86_64pigsty119.7 KiBpostgresql-18-pg-ivm_1.14-1PIGSTY~bookworm_amd64.deb
postgresql-18-pg-ivm1.13d12.x86_64pgdg118.7 KiBpostgresql-18-pg-ivm_1.13-1.pgdg12+1_amd64.deb
postgresql-18-pg-ivm1.14d12.aarch64pigsty116.2 KiBpostgresql-18-pg-ivm_1.14-1PIGSTY~bookworm_arm64.deb
postgresql-18-pg-ivm1.13d12.aarch64pgdg115.4 KiBpostgresql-18-pg-ivm_1.13-1.pgdg12+1_arm64.deb
postgresql-18-pg-ivm1.14d13.x86_64pigsty119.7 KiBpostgresql-18-pg-ivm_1.14-1PIGSTY~trixie_amd64.deb
postgresql-18-pg-ivm1.13d13.x86_64pgdg118.8 KiBpostgresql-18-pg-ivm_1.13-1.pgdg13+1_amd64.deb
postgresql-18-pg-ivm1.14d13.aarch64pigsty116.0 KiBpostgresql-18-pg-ivm_1.14-1PIGSTY~trixie_arm64.deb
postgresql-18-pg-ivm1.13d13.aarch64pgdg114.9 KiBpostgresql-18-pg-ivm_1.13-1.pgdg13+1_arm64.deb
postgresql-18-pg-ivm1.14u22.x86_64pigsty130.9 KiBpostgresql-18-pg-ivm_1.14-1PIGSTY~jammy_amd64.deb
postgresql-18-pg-ivm1.13u22.x86_64pgdg121.6 KiBpostgresql-18-pg-ivm_1.13-1.pgdg22.04+1_amd64.deb
postgresql-18-pg-ivm1.14u22.aarch64pigsty128.2 KiBpostgresql-18-pg-ivm_1.14-1PIGSTY~jammy_arm64.deb
postgresql-18-pg-ivm1.13u22.aarch64pgdg117.9 KiBpostgresql-18-pg-ivm_1.13-1.pgdg22.04+1_arm64.deb
postgresql-18-pg-ivm1.14u24.x86_64pigsty125.2 KiBpostgresql-18-pg-ivm_1.14-1PIGSTY~noble_amd64.deb
postgresql-18-pg-ivm1.13u24.x86_64pgdg118.7 KiBpostgresql-18-pg-ivm_1.13-1.pgdg24.04+1_amd64.deb
postgresql-18-pg-ivm1.14u24.aarch64pigsty123.0 KiBpostgresql-18-pg-ivm_1.14-1PIGSTY~noble_arm64.deb
postgresql-18-pg-ivm1.13u24.aarch64pgdg114.9 KiBpostgresql-18-pg-ivm_1.13-1.pgdg24.04+1_arm64.deb
postgresql-18-pg-ivm1.14u26.x86_64pigsty123.7 KiBpostgresql-18-pg-ivm_1.14-1PIGSTY~resolute_amd64.deb
postgresql-18-pg-ivm1.13u26.x86_64pgdg117.1 KiBpostgresql-18-pg-ivm_1.13-1.pgdg26.04+1_amd64.deb
postgresql-18-pg-ivm1.14u26.aarch64pigsty121.8 KiBpostgresql-18-pg-ivm_1.14-1PIGSTY~resolute_arm64.deb
postgresql-18-pg-ivm1.13u26.aarch64pgdg113.6 KiBpostgresql-18-pg-ivm_1.13-1.pgdg26.04+1_arm64.deb

Source

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

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

Config this extension to shared_preload_libraries:

shared_preload_libraries = 'pg_ivm';

Create this extension with:

CREATE EXTENSION pg_ivm;

Usage

Sources: README, release 1.14

pg_ivm provides immediate Incremental View Maintenance for PostgreSQL materialized views. Instead of recomputing the whole view, it applies deltas in AFTER triggers and stores metadata in the pgivm schema.

CREATE EXTENSION pg_ivm;

Required Setup

Upstream says pg_ivm should be preloaded so IMMVs are maintained correctly:

shared_preload_libraries = 'pg_ivm'
session_preload_libraries = 'pg_ivm'

The current README says the extension is compatible with PostgreSQL 13 through 18, and the latest GitHub release is 1.14 dated March 31, 2026.

Main Functions

  • pgivm.create_immv(name, query) creates an incrementally maintainable materialized view (IMMV), its maintenance triggers, and a unique index when possible.
  • pgivm.refresh_immv(name, with_data) fully refreshes the IMMV and can disable or re-enable maintenance.
  • pgivm.get_immv_def(regclass) reconstructs the stored SELECT definition.
  • pgivm.pg_ivm_immv stores IMMV metadata including immvrelid, viewdef, ispopulated, and lastivmupdate.

Common Patterns

Create an IMMV:

SELECT pgivm.create_immv(
  'immv_agg',
  'SELECT bid, count(*), sum(abalance), avg(abalance)
   FROM pgbench_accounts JOIN pgbench_branches USING(bid)
   GROUP BY bid'
);

Query the maintained result after base-table changes:

UPDATE pgbench_accounts SET abalance = abalance + 1000 WHERE aid = 4112345;
SELECT * FROM immv_agg WHERE bid = 42;

Inspect or refresh IMMVs:

SELECT immvrelid AS immv, pgivm.get_immv_def(immvrelid)
FROM pgivm.pg_ivm_immv;

SELECT pgivm.refresh_immv('immv_agg', true);

Pause maintenance for bulk work, then rebuild:

SELECT pgivm.refresh_immv('myview', false);
-- bulk changes
SELECT pgivm.refresh_immv('myview', true);

Caveats

  • Upstream only supports a restricted subset of view definitions: joins, DISTINCT, simple subqueries/CTEs, and built-in aggregates count, sum, avg, min, and max.
  • Unsupported constructs include HAVING, window functions, ORDER BY, LIMIT/OFFSET, UNION/INTERSECT/EXCEPT, DISTINCT ON, and user-defined aggregates.
  • Efficient maintenance depends on having a suitable unique index; create_immv creates one automatically only when the definition allows it.
Last updated on