Skip to content
pg_ivm

pg_ivm

pg_ivm : incremental view maintenance on PostgreSQL

Overview

ID Extension Package Version Category License Language
2840
pg_ivm
pg_ivm
1.14
FEAT
PostgreSQL
C
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--sLd--
No
Yes
Yes
Yes
no
no
Relationships
Schemas pg_catalog
See Also
age
hll
rum
pg_graphql
pg_jsonschema
jsquery
pg_hint_plan

deb takeover by pgdg since 2026-01

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
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 / PG PG18 PG17 PG16 PG15 PG14
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
Package Version OS ORG SIZE File URL
pg_ivm_18 1.14 el8.x86_64 pigsty 57.9 KiB pg_ivm_18-1.14-1PIGSTY.el8.x86_64.rpm
pg_ivm_18 1.14 el8.x86_64 pgdg 50.3 KiB pg_ivm_18-1.14-1PGDG.rhel8.10.x86_64.rpm
pg_ivm_18 1.13 el8.x86_64 pgdg 49.5 KiB pg_ivm_18-1.13-1PGDG.rhel8.x86_64.rpm
pg_ivm_18 1.12 el8.x86_64 pgdg 43.3 KiB pg_ivm_18-1.12-1PGDG.rhel8.x86_64.rpm
pg_ivm_18 1.14 el8.aarch64 pigsty 55.9 KiB pg_ivm_18-1.14-1PIGSTY.el8.aarch64.rpm
pg_ivm_18 1.14 el8.aarch64 pgdg 48.1 KiB pg_ivm_18-1.14-1PGDG.rhel8.10.aarch64.rpm
pg_ivm_18 1.13 el8.aarch64 pgdg 47.5 KiB pg_ivm_18-1.13-1PGDG.rhel8.aarch64.rpm
pg_ivm_18 1.12 el8.aarch64 pgdg 41.2 KiB pg_ivm_18-1.12-1PGDG.rhel8.aarch64.rpm
pg_ivm_18 1.14 el9.x86_64 pigsty 57.5 KiB pg_ivm_18-1.14-1PIGSTY.el9.x86_64.rpm
pg_ivm_18 1.14 el9.x86_64 pgdg 49.7 KiB pg_ivm_18-1.14-1PGDG.rhel9.7.x86_64.rpm
pg_ivm_18 1.13 el9.x86_64 pgdg 49.3 KiB pg_ivm_18-1.13-1PGDG.rhel9.x86_64.rpm
pg_ivm_18 1.12 el9.x86_64 pgdg 43.3 KiB pg_ivm_18-1.12-1PGDG.rhel9.x86_64.rpm
pg_ivm_18 1.14 el9.aarch64 pigsty 56.3 KiB pg_ivm_18-1.14-1PIGSTY.el9.aarch64.rpm
pg_ivm_18 1.14 el9.aarch64 pgdg 48.3 KiB pg_ivm_18-1.14-1PGDG.rhel9.7.aarch64.rpm
pg_ivm_18 1.13 el9.aarch64 pgdg 48.1 KiB pg_ivm_18-1.13-1PGDG.rhel9.aarch64.rpm
pg_ivm_18 1.12 el9.aarch64 pgdg 42.0 KiB pg_ivm_18-1.12-1PGDG.rhel9.aarch64.rpm
pg_ivm_18 1.14 el10.x86_64 pigsty 58.5 KiB pg_ivm_18-1.14-1PIGSTY.el10.x86_64.rpm
pg_ivm_18 1.14 el10.x86_64 pgdg 50.8 KiB pg_ivm_18-1.14-1PGDG.rhel10.1.x86_64.rpm
pg_ivm_18 1.13 el10.x86_64 pgdg 50.6 KiB pg_ivm_18-1.13-1PGDG.rhel10.x86_64.rpm
pg_ivm_18 1.12 el10.x86_64 pgdg 44.1 KiB pg_ivm_18-1.12-1PGDG.rhel10.x86_64.rpm
pg_ivm_18 1.14 el10.aarch64 pigsty 57.4 KiB pg_ivm_18-1.14-1PIGSTY.el10.aarch64.rpm
pg_ivm_18 1.14 el10.aarch64 pgdg 49.5 KiB pg_ivm_18-1.14-1PGDG.rhel10.1.aarch64.rpm
pg_ivm_18 1.13 el10.aarch64 pgdg 49.7 KiB pg_ivm_18-1.13-1PGDG.rhel10.aarch64.rpm
pg_ivm_18 1.12 el10.aarch64 pgdg 42.8 KiB pg_ivm_18-1.12-1PGDG.rhel10.aarch64.rpm
postgresql-18-pg-ivm 1.14 d12.x86_64 pigsty 119.7 KiB postgresql-18-pg-ivm_1.14-1PIGSTY~bookworm_amd64.deb
postgresql-18-pg-ivm 1.13 d12.x86_64 pgdg 118.7 KiB postgresql-18-pg-ivm_1.13-1.pgdg12+1_amd64.deb
postgresql-18-pg-ivm 1.14 d12.aarch64 pigsty 116.2 KiB postgresql-18-pg-ivm_1.14-1PIGSTY~bookworm_arm64.deb
postgresql-18-pg-ivm 1.13 d12.aarch64 pgdg 115.4 KiB postgresql-18-pg-ivm_1.13-1.pgdg12+1_arm64.deb
postgresql-18-pg-ivm 1.14 d13.x86_64 pigsty 119.7 KiB postgresql-18-pg-ivm_1.14-1PIGSTY~trixie_amd64.deb
postgresql-18-pg-ivm 1.13 d13.x86_64 pgdg 118.8 KiB postgresql-18-pg-ivm_1.13-1.pgdg13+1_amd64.deb
postgresql-18-pg-ivm 1.14 d13.aarch64 pigsty 116.0 KiB postgresql-18-pg-ivm_1.14-1PIGSTY~trixie_arm64.deb
postgresql-18-pg-ivm 1.13 d13.aarch64 pgdg 114.9 KiB postgresql-18-pg-ivm_1.13-1.pgdg13+1_arm64.deb
postgresql-18-pg-ivm 1.14 u22.x86_64 pigsty 130.9 KiB postgresql-18-pg-ivm_1.14-1PIGSTY~jammy_amd64.deb
postgresql-18-pg-ivm 1.13 u22.x86_64 pgdg 121.6 KiB postgresql-18-pg-ivm_1.13-1.pgdg22.04+1_amd64.deb
postgresql-18-pg-ivm 1.14 u22.aarch64 pigsty 128.2 KiB postgresql-18-pg-ivm_1.14-1PIGSTY~jammy_arm64.deb
postgresql-18-pg-ivm 1.13 u22.aarch64 pgdg 117.9 KiB postgresql-18-pg-ivm_1.13-1.pgdg22.04+1_arm64.deb
postgresql-18-pg-ivm 1.14 u24.x86_64 pigsty 125.2 KiB postgresql-18-pg-ivm_1.14-1PIGSTY~noble_amd64.deb
postgresql-18-pg-ivm 1.13 u24.x86_64 pgdg 118.7 KiB postgresql-18-pg-ivm_1.13-1.pgdg24.04+1_amd64.deb
postgresql-18-pg-ivm 1.14 u24.aarch64 pigsty 123.0 KiB postgresql-18-pg-ivm_1.14-1PIGSTY~noble_arm64.deb
postgresql-18-pg-ivm 1.13 u24.aarch64 pgdg 114.9 KiB postgresql-18-pg-ivm_1.13-1.pgdg24.04+1_arm64.deb
postgresql-18-pg-ivm 1.14 u26.x86_64 pigsty 123.7 KiB postgresql-18-pg-ivm_1.14-1PIGSTY~resolute_amd64.deb
postgresql-18-pg-ivm 1.13 u26.x86_64 pgdg 117.1 KiB postgresql-18-pg-ivm_1.13-1.pgdg26.04+1_amd64.deb
postgresql-18-pg-ivm 1.14 u26.aarch64 pigsty 121.8 KiB postgresql-18-pg-ivm_1.14-1PIGSTY~resolute_arm64.deb
postgresql-18-pg-ivm 1.13 u26.aarch64 pgdg 113.6 KiB postgresql-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