Skip to content
pgfincore

pgfincore

pgfincore : examine and manage the os buffer cache

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
5060
pgfincore
pgfincore
1.3.1
ADMIN
BSD 3-Clause
C
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-d-r
No
Yes
No
Yes
yes
no
Relationships
See Also
pg_cooldown
pgcozy
fio
pg_prewarm
pgmeminfo
pg_buffercache
pg_repack
pg_rewrite

pg18 el fixed by vonng

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXT
PGDG
1.3.1
18
17
16
15
14
pgfincore-
RPM
PGDG
1.3.1
18
17
16
15
14
pgfincore_$v-
DEB
PGDG
1.3.1
18
17
16
15
14
postgresql-$v-pgfincore-
Linux / PGPG18PG17PG16PG15PG14
el8.x86_64
PIGSTY 1.3.1
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.3.1
el8.aarch64
PIGSTY 1.3.1
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.3.1
el9.x86_64
PIGSTY 1.3.1
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.2.4
PGDG 1.2.4
el9.aarch64
PIGSTY 1.3.1
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.2.4
PGDG 1.2.4
el10.x86_64
PIGSTY 1.3.1
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.3.1
el10.aarch64
PIGSTY 1.3.1
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.3.1
d12.x86_64
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.3.1
d12.aarch64
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.3.1
d13.x86_64
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.3.1
d13.aarch64
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.3.1
u22.x86_64
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.3.1
u22.aarch64
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.3.1
u24.x86_64
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.3.1
u24.aarch64
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.3.1
u26.x86_64
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.3.1
u26.aarch64
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.3.1
PGDG 1.3.1
PackageVersionOSORGSIZEFile URL
pgfincore_181.3.1el8.x86_64pigsty16.6 KiBpgfincore_18-1.3.1-1PIGSTY.el8.x86_64.rpm
pgfincore_181.3.1el8.aarch64pigsty16.4 KiBpgfincore_18-1.3.1-1PIGSTY.el8.aarch64.rpm
pgfincore_181.3.1el9.x86_64pigsty16.7 KiBpgfincore_18-1.3.1-1PIGSTY.el9.x86_64.rpm
pgfincore_181.3.1el9.aarch64pigsty16.3 KiBpgfincore_18-1.3.1-1PIGSTY.el9.aarch64.rpm
pgfincore_181.3.1el10.x86_64pigsty16.8 KiBpgfincore_18-1.3.1-1PIGSTY.el10.x86_64.rpm
pgfincore_181.3.1el10.aarch64pigsty16.6 KiBpgfincore_18-1.3.1-1PIGSTY.el10.aarch64.rpm
postgresql-18-pgfincore1.3.1d12.x86_64pgdg28.8 KiBpostgresql-18-pgfincore_1.3.1-3.pgdg12+1_amd64.deb
postgresql-18-pgfincore1.3.1d12.aarch64pgdg28.4 KiBpostgresql-18-pgfincore_1.3.1-3.pgdg12+1_arm64.deb
postgresql-18-pgfincore1.3.1d13.x86_64pgdg29.0 KiBpostgresql-18-pgfincore_1.3.1-3.pgdg13+1_amd64.deb
postgresql-18-pgfincore1.3.1d13.aarch64pgdg28.4 KiBpostgresql-18-pgfincore_1.3.1-3.pgdg13+1_arm64.deb
postgresql-18-pgfincore1.3.1u22.x86_64pgdg27.6 KiBpostgresql-18-pgfincore_1.3.1-3.pgdg22.04+1_amd64.deb
postgresql-18-pgfincore1.3.1u22.aarch64pgdg27.1 KiBpostgresql-18-pgfincore_1.3.1-3.pgdg22.04+1_arm64.deb
postgresql-18-pgfincore1.3.1u24.x86_64pgdg27.4 KiBpostgresql-18-pgfincore_1.3.1-3.pgdg24.04+1_amd64.deb
postgresql-18-pgfincore1.3.1u24.aarch64pgdg26.7 KiBpostgresql-18-pgfincore_1.3.1-3.pgdg24.04+1_arm64.deb
postgresql-18-pgfincore1.3.1u26.x86_64pgdg26.9 KiBpostgresql-18-pgfincore_1.3.1-3.pgdg26.04+1_amd64.deb
postgresql-18-pgfincore1.3.1u26.x86_64pigsty26.6 KiBpostgresql-18-pgfincore_1.3.1-1PIGSTY~resolute_amd64.deb
postgresql-18-pgfincore1.3.1u26.aarch64pgdg26.2 KiBpostgresql-18-pgfincore_1.3.1-3.pgdg26.04+1_arm64.deb
postgresql-18-pgfincore1.3.1u26.aarch64pigsty26.2 KiBpostgresql-18-pgfincore_1.3.1-1PIGSTY~resolute_arm64.deb

Source

pig build pkg pgfincore;		# build rpm/deb

Install

Make sure PGDG repo available:

pig repo add pgdg -u    # add pgdg repo and update cache

Install this extension with pig:

pig install pgfincore;		# install via package name, for the active PG version

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

Create this extension with:

CREATE EXTENSION pgfincore;

Usage

pgfincore: examine and manage the os buffer cache

pgfincore provides functions to inspect and manage OS page cache contents for PostgreSQL relations using mincore and POSIX_FADVISE.

Inspect Cache State

SELECT * FROM pgfincore('pgbench_accounts');

Returns per-segment info: relpath, segment, os_page_size, rel_os_pages, pages_mem (pages in OS cache), group_mem, os_pages_free, pages_dirty, group_dirty.

Use pgfincore('relation', true) to include the databit varbit map for snapshot/restore.

System Info

SELECT * FROM pgsysconf();          -- os_page_size, os_pages_free, os_total_pages
SELECT * FROM pgsysconf_pretty();   -- same with human-readable output

Preload into OS Cache

SELECT * FROM pgfadvise_willneed('pgbench_accounts');

Evict from OS Cache

SELECT * FROM pgfadvise_dontneed('pgbench_accounts');

Other POSIX_FADVISE Flags

SELECT * FROM pgfadvise_normal('relation');
SELECT * FROM pgfadvise_sequential('relation');
SELECT * FROM pgfadvise_random('relation');

Snapshot and Restore Cache State

-- Snapshot
CREATE TABLE pgfincore_snapshot AS
  SELECT 'pgbench_accounts'::text AS relname, *, now() AS date_snapshot
  FROM pgfincore('pgbench_accounts', true);

-- Restore
SELECT * FROM pgfadvise_loader('pgbench_accounts', 0, true, true,
               (SELECT databit FROM pgfincore_snapshot
                WHERE relname = 'pgbench_accounts' AND segment = 0));

Direct Page Cache Control

-- Load first 3 pages, unload next 3
SELECT * FROM pgfadvise_loader('pgbench_accounts', 0, true, true, B'111000');
-- Load only
SELECT * FROM pgfadvise_loader('pgbench_accounts', 0, true, false, B'111000');
-- Unload only
SELECT * FROM pgfadvise_loader('pgbench_accounts', 0, false, true, B'111000');
Last updated on