pgcozy

pgcozy : Pre-warming shared buffers according to previous pg_buffercache snapshots for PostgreSQL.

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
5190
pgcozy
pgcozy
1.0
ADMIN
PostgreSQL
SQL
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
----d--
No
No
No
Yes
no
no
Relationships
Requires
pg_buffercache
pg_prewarm
See Also
pgfincore
pg_cooldown
pg_prewarm
pg_buffercache
pg_repack
pg_squeeze
pg_visibility
system_stats

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXT
PIGSTY
1.0
18
17
16
15
14
pgcozypg_buffercache, pg_prewarm
RPM
PIGSTY
1.0
18
17
16
15
14
pgcozy_$v-
DEB
PIGSTY
1.0
18
17
16
15
14
postgresql-$v-pgcozy-
Linux / PGPG18PG17PG16PG15PG14
el8.x86_64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
el8.aarch64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
el9.x86_64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
el9.aarch64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
el10.x86_64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
el10.aarch64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
d12.x86_64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
d12.aarch64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
d13.x86_64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
d13.aarch64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
u22.x86_64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
u22.aarch64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
u24.x86_64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
u24.aarch64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0

Source

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

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

Create this extension with:

CREATE EXTENSION pgcozy CASCADE; -- requires pg_buffercache, pg_prewarm

Usage

pgcozy: Pre-warming shared buffers according to previous pg_buffercache snapshots for PostgreSQL.

pgcozy snapshots the current shared buffer state and can later restore (pre-warm) buffers from those snapshots. Requires pg_buffercache and pg_prewarm extensions.

Initialize

SELECT pgcozy_init();

Creates the pgcozy schema with a snapshots table and the cozy_type type.

Take a Snapshot

-- Snapshot buffer pages with usagecount >= 3 (popularity 1-5)
SELECT pgcozy_snapshot(3);

-- Snapshot all buffered pages (popularity = 0)
SELECT pgcozy_snapshot(0);

Snapshots are stored as JSONB in pgcozy.snapshots with columns: id, snapshot_date, snapshot. Each entry contains table_name, block_no, and popularity.

Warm from a Snapshot

-- Warm from a specific snapshot by ID
SELECT pgcozy_warm(1);

-- Warm from the latest snapshot
SELECT pgcozy_warm(0);

Review Snapshots

SELECT id, snapshot_date FROM pgcozy.snapshots;

Snapshots are stored in JSONB and can be reviewed, backed up, or transferred between servers.

Last updated on