pgcozy

pgcozy

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

Overview

ID Extension Package Version Category License Language
5190
pgcozy
pgcozy
1.0
ADMIN
PostgreSQL
SQL
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
----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

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT
PIGSTY
1.0
18
17
16
15
14
pgcozy pg_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 / PG PG18 PG17 PG16 PG15 PG14
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
Package Version OS ORG SIZE File URL
pgcozy_18 1.0 el8.x86_64 pigsty 10.7 KiB pgcozy_18-1.0-1PIGSTY.el8.x86_64.rpm
pgcozy_18 1.0 el8.aarch64 pigsty 10.7 KiB pgcozy_18-1.0-1PIGSTY.el8.aarch64.rpm
pgcozy_18 1.0 el9.x86_64 pigsty 10.7 KiB pgcozy_18-1.0-1PIGSTY.el9.x86_64.rpm
pgcozy_18 1.0 el9.aarch64 pigsty 10.7 KiB pgcozy_18-1.0-1PIGSTY.el9.aarch64.rpm
pgcozy_18 1.0 el10.x86_64 pigsty 10.8 KiB pgcozy_18-1.0-1PIGSTY.el10.x86_64.rpm
pgcozy_18 1.0 el10.aarch64 pigsty 10.8 KiB pgcozy_18-1.0-1PIGSTY.el10.aarch64.rpm
postgresql-18-pgcozy 1.0 d12.x86_64 pigsty 8.2 KiB postgresql-18-pgcozy_1.0-1PIGSTY~bookworm_amd64.deb
postgresql-18-pgcozy 1.0 d12.aarch64 pigsty 8.2 KiB postgresql-18-pgcozy_1.0-1PIGSTY~bookworm_arm64.deb
postgresql-18-pgcozy 1.0 d13.x86_64 pigsty 8.2 KiB postgresql-18-pgcozy_1.0-1PIGSTY~trixie_amd64.deb
postgresql-18-pgcozy 1.0 d13.aarch64 pigsty 8.2 KiB postgresql-18-pgcozy_1.0-1PIGSTY~trixie_arm64.deb
postgresql-18-pgcozy 1.0 u22.x86_64 pigsty 8.2 KiB postgresql-18-pgcozy_1.0-1PIGSTY~jammy_amd64.deb
postgresql-18-pgcozy 1.0 u22.aarch64 pigsty 8.2 KiB postgresql-18-pgcozy_1.0-1PIGSTY~jammy_arm64.deb
postgresql-18-pgcozy 1.0 u24.x86_64 pigsty 8.2 KiB postgresql-18-pgcozy_1.0-1PIGSTY~noble_amd64.deb
postgresql-18-pgcozy 1.0 u24.aarch64 pigsty 8.2 KiB postgresql-18-pgcozy_1.0-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pgcozy_17 1.0 el8.x86_64 pigsty 10.7 KiB pgcozy_17-1.0-1PIGSTY.el8.x86_64.rpm
pgcozy_17 1.0 el8.aarch64 pigsty 10.7 KiB pgcozy_17-1.0-1PIGSTY.el8.aarch64.rpm
pgcozy_17 1.0 el9.x86_64 pigsty 10.7 KiB pgcozy_17-1.0-1PIGSTY.el9.x86_64.rpm
pgcozy_17 1.0 el9.aarch64 pigsty 10.7 KiB pgcozy_17-1.0-1PIGSTY.el9.aarch64.rpm
pgcozy_17 1.0 el10.x86_64 pigsty 10.8 KiB pgcozy_17-1.0-1PIGSTY.el10.x86_64.rpm
pgcozy_17 1.0 el10.aarch64 pigsty 10.8 KiB pgcozy_17-1.0-1PIGSTY.el10.aarch64.rpm
postgresql-17-pgcozy 1.0 d12.x86_64 pigsty 8.2 KiB postgresql-17-pgcozy_1.0-1PIGSTY~bookworm_amd64.deb
postgresql-17-pgcozy 1.0 d12.aarch64 pigsty 8.2 KiB postgresql-17-pgcozy_1.0-1PIGSTY~bookworm_arm64.deb
postgresql-17-pgcozy 1.0 d13.x86_64 pigsty 8.2 KiB postgresql-17-pgcozy_1.0-1PIGSTY~trixie_amd64.deb
postgresql-17-pgcozy 1.0 d13.aarch64 pigsty 8.2 KiB postgresql-17-pgcozy_1.0-1PIGSTY~trixie_arm64.deb
postgresql-17-pgcozy 1.0 u22.x86_64 pigsty 8.2 KiB postgresql-17-pgcozy_1.0-1PIGSTY~jammy_amd64.deb
postgresql-17-pgcozy 1.0 u22.aarch64 pigsty 8.2 KiB postgresql-17-pgcozy_1.0-1PIGSTY~jammy_arm64.deb
postgresql-17-pgcozy 1.0 u24.x86_64 pigsty 8.2 KiB postgresql-17-pgcozy_1.0-1PIGSTY~noble_amd64.deb
postgresql-17-pgcozy 1.0 u24.aarch64 pigsty 8.2 KiB postgresql-17-pgcozy_1.0-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pgcozy_16 1.0 el8.x86_64 pigsty 10.7 KiB pgcozy_16-1.0-1PIGSTY.el8.x86_64.rpm
pgcozy_16 1.0 el8.aarch64 pigsty 10.7 KiB pgcozy_16-1.0-1PIGSTY.el8.aarch64.rpm
pgcozy_16 1.0 el9.x86_64 pigsty 10.7 KiB pgcozy_16-1.0-1PIGSTY.el9.x86_64.rpm
pgcozy_16 1.0 el9.aarch64 pigsty 10.7 KiB pgcozy_16-1.0-1PIGSTY.el9.aarch64.rpm
pgcozy_16 1.0 el10.x86_64 pigsty 10.8 KiB pgcozy_16-1.0-1PIGSTY.el10.x86_64.rpm
pgcozy_16 1.0 el10.aarch64 pigsty 10.8 KiB pgcozy_16-1.0-1PIGSTY.el10.aarch64.rpm
postgresql-16-pgcozy 1.0 d12.x86_64 pigsty 8.2 KiB postgresql-16-pgcozy_1.0-1PIGSTY~bookworm_amd64.deb
postgresql-16-pgcozy 1.0 d12.aarch64 pigsty 8.2 KiB postgresql-16-pgcozy_1.0-1PIGSTY~bookworm_arm64.deb
postgresql-16-pgcozy 1.0 d13.x86_64 pigsty 8.2 KiB postgresql-16-pgcozy_1.0-1PIGSTY~trixie_amd64.deb
postgresql-16-pgcozy 1.0 d13.aarch64 pigsty 8.2 KiB postgresql-16-pgcozy_1.0-1PIGSTY~trixie_arm64.deb
postgresql-16-pgcozy 1.0 u22.x86_64 pigsty 8.2 KiB postgresql-16-pgcozy_1.0-1PIGSTY~jammy_amd64.deb
postgresql-16-pgcozy 1.0 u22.aarch64 pigsty 8.2 KiB postgresql-16-pgcozy_1.0-1PIGSTY~jammy_arm64.deb
postgresql-16-pgcozy 1.0 u24.x86_64 pigsty 8.2 KiB postgresql-16-pgcozy_1.0-1PIGSTY~noble_amd64.deb
postgresql-16-pgcozy 1.0 u24.aarch64 pigsty 8.2 KiB postgresql-16-pgcozy_1.0-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pgcozy_15 1.0 el8.x86_64 pigsty 10.7 KiB pgcozy_15-1.0-1PIGSTY.el8.x86_64.rpm
pgcozy_15 1.0 el8.aarch64 pigsty 10.7 KiB pgcozy_15-1.0-1PIGSTY.el8.aarch64.rpm
pgcozy_15 1.0 el9.x86_64 pigsty 10.7 KiB pgcozy_15-1.0-1PIGSTY.el9.x86_64.rpm
pgcozy_15 1.0 el9.aarch64 pigsty 10.7 KiB pgcozy_15-1.0-1PIGSTY.el9.aarch64.rpm
pgcozy_15 1.0 el10.x86_64 pigsty 10.8 KiB pgcozy_15-1.0-1PIGSTY.el10.x86_64.rpm
pgcozy_15 1.0 el10.aarch64 pigsty 10.8 KiB pgcozy_15-1.0-1PIGSTY.el10.aarch64.rpm
postgresql-15-pgcozy 1.0 d12.x86_64 pigsty 8.2 KiB postgresql-15-pgcozy_1.0-1PIGSTY~bookworm_amd64.deb
postgresql-15-pgcozy 1.0 d12.aarch64 pigsty 8.2 KiB postgresql-15-pgcozy_1.0-1PIGSTY~bookworm_arm64.deb
postgresql-15-pgcozy 1.0 d13.x86_64 pigsty 8.2 KiB postgresql-15-pgcozy_1.0-1PIGSTY~trixie_amd64.deb
postgresql-15-pgcozy 1.0 d13.aarch64 pigsty 8.2 KiB postgresql-15-pgcozy_1.0-1PIGSTY~trixie_arm64.deb
postgresql-15-pgcozy 1.0 u22.x86_64 pigsty 8.2 KiB postgresql-15-pgcozy_1.0-1PIGSTY~jammy_amd64.deb
postgresql-15-pgcozy 1.0 u22.aarch64 pigsty 8.2 KiB postgresql-15-pgcozy_1.0-1PIGSTY~jammy_arm64.deb
postgresql-15-pgcozy 1.0 u24.x86_64 pigsty 8.2 KiB postgresql-15-pgcozy_1.0-1PIGSTY~noble_amd64.deb
postgresql-15-pgcozy 1.0 u24.aarch64 pigsty 8.2 KiB postgresql-15-pgcozy_1.0-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pgcozy_14 1.0 el8.x86_64 pigsty 10.7 KiB pgcozy_14-1.0-1PIGSTY.el8.x86_64.rpm
pgcozy_14 1.0 el8.aarch64 pigsty 10.7 KiB pgcozy_14-1.0-1PIGSTY.el8.aarch64.rpm
pgcozy_14 1.0 el9.x86_64 pigsty 10.7 KiB pgcozy_14-1.0-1PIGSTY.el9.x86_64.rpm
pgcozy_14 1.0 el9.aarch64 pigsty 10.7 KiB pgcozy_14-1.0-1PIGSTY.el9.aarch64.rpm
pgcozy_14 1.0 el10.x86_64 pigsty 10.8 KiB pgcozy_14-1.0-1PIGSTY.el10.x86_64.rpm
pgcozy_14 1.0 el10.aarch64 pigsty 10.8 KiB pgcozy_14-1.0-1PIGSTY.el10.aarch64.rpm
postgresql-14-pgcozy 1.0 d12.x86_64 pigsty 8.2 KiB postgresql-14-pgcozy_1.0-1PIGSTY~bookworm_amd64.deb
postgresql-14-pgcozy 1.0 d12.aarch64 pigsty 8.2 KiB postgresql-14-pgcozy_1.0-1PIGSTY~bookworm_arm64.deb
postgresql-14-pgcozy 1.0 d13.x86_64 pigsty 8.2 KiB postgresql-14-pgcozy_1.0-1PIGSTY~trixie_amd64.deb
postgresql-14-pgcozy 1.0 d13.aarch64 pigsty 8.2 KiB postgresql-14-pgcozy_1.0-1PIGSTY~trixie_arm64.deb
postgresql-14-pgcozy 1.0 u22.x86_64 pigsty 8.2 KiB postgresql-14-pgcozy_1.0-1PIGSTY~jammy_amd64.deb
postgresql-14-pgcozy 1.0 u22.aarch64 pigsty 8.2 KiB postgresql-14-pgcozy_1.0-1PIGSTY~jammy_arm64.deb
postgresql-14-pgcozy 1.0 u24.x86_64 pigsty 8.2 KiB postgresql-14-pgcozy_1.0-1PIGSTY~noble_amd64.deb
postgresql-14-pgcozy 1.0 u24.aarch64 pigsty 8.2 KiB postgresql-14-pgcozy_1.0-1PIGSTY~noble_arm64.deb

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