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
PackageVersionOSORGSIZEFile URL
pgfincore_141.3.1el8.x86_64pgdg24.3 KiBpgfincore_14-1.3.1-1PGDG.rhel8.x86_64.rpm
pgfincore_141.2.4el8.x86_64pgdg24.0 KiBpgfincore_14-1.2.4-1.rhel8.x86_64.rpm
pgfincore_141.2.2el8.x86_64pgdg41.0 KiBpgfincore_14-1.2.2-3.rhel8.x86_64.rpm
pgfincore_141.3.1el8.aarch64pgdg24.0 KiBpgfincore_14-1.3.1-1PGDG.rhel8.aarch64.rpm
pgfincore_141.2.4el8.aarch64pgdg23.7 KiBpgfincore_14-1.2.4-1.rhel8.aarch64.rpm
pgfincore_141.2.4el9.x86_64pgdg23.7 KiBpgfincore_14-1.2.4-1.rhel9.x86_64.rpm
pgfincore_141.2.4el9.aarch64pgdg23.1 KiBpgfincore_14-1.2.4-1.rhel9.aarch64.rpm
pgfincore_141.3.1el10.x86_64pgdg24.1 KiBpgfincore_14-1.3.1-4PGDG.rhel10.x86_64.rpm
pgfincore_141.3.1el10.aarch64pgdg23.7 KiBpgfincore_14-1.3.1-4PGDG.rhel10.aarch64.rpm
postgresql-14-pgfincore1.3.1d12.x86_64pgdg28.6 KiBpostgresql-14-pgfincore_1.3.1-3.pgdg12+1_amd64.deb
postgresql-14-pgfincore1.3.1d12.aarch64pgdg27.9 KiBpostgresql-14-pgfincore_1.3.1-3.pgdg12+1_arm64.deb
postgresql-14-pgfincore1.3.1d13.x86_64pgdg28.7 KiBpostgresql-14-pgfincore_1.3.1-3.pgdg13+1_amd64.deb
postgresql-14-pgfincore1.3.1d13.aarch64pgdg28.0 KiBpostgresql-14-pgfincore_1.3.1-3.pgdg13+1_arm64.deb
postgresql-14-pgfincore1.3.1u22.x86_64pgdg31.3 KiBpostgresql-14-pgfincore_1.3.1-3.pgdg22.04+1_amd64.deb
postgresql-14-pgfincore1.3.1u22.aarch64pgdg30.7 KiBpostgresql-14-pgfincore_1.3.1-3.pgdg22.04+1_arm64.deb
postgresql-14-pgfincore1.3.1u24.x86_64pgdg27.1 KiBpostgresql-14-pgfincore_1.3.1-3.pgdg24.04+1_amd64.deb
postgresql-14-pgfincore1.3.1u24.aarch64pgdg26.3 KiBpostgresql-14-pgfincore_1.3.1-3.pgdg24.04+1_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