pgfincore
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pgfincore | 1.3.1 | ADMIN | BSD 3-Clause | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 5060 | pgfincore | No | Yes | No | Yes | No | Yes | - |
| Related | pg_cooldown pgcozy fio pg_prewarm pgmeminfo pg_buffercache pg_repack pg_rewrite |
|---|
pg18 el fixed by vonng
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PGDG | 1.3.1 | 1817161514 | pgfincore | - |
| RPM | PGDG | 1.3.1 | 1817161514 | pgfincore_$v | - |
| DEB | PGDG | 1.3.1 | 1817161514 | postgresql-$v-pgfincore | - |
Build
You can build the RPM / DEB packages for pgfincore using pig build:
pig build pkg pgfincore # build RPM / DEB packages
Install
You can install pgfincore directly. First, make sure the PGDG repository is added and enabled:
pig repo add pgdg -u # Add PGDG repo and update cache
Install the extension using pig or apt/yum/dnf:
pig install pgfincore; # Install for current active PG version
pig ext install -y pgfincore -v 18 # PG 18
pig ext install -y pgfincore -v 17 # PG 17
pig ext install -y pgfincore -v 16 # PG 16
pig ext install -y pgfincore -v 15 # PG 15
pig ext install -y pgfincore -v 14 # PG 14
dnf install -y pgfincore_18 # PG 18
dnf install -y pgfincore_17 # PG 17
dnf install -y pgfincore_16 # PG 16
dnf install -y pgfincore_15 # PG 15
dnf install -y pgfincore_14 # PG 14
apt install -y postgresql-18-pgfincore # PG 18
apt install -y postgresql-17-pgfincore # PG 17
apt install -y postgresql-16-pgfincore # PG 16
apt install -y postgresql-15-pgfincore # PG 15
apt install -y postgresql-14-pgfincore # PG 14
Create Extension:
CREATE EXTENSION pgfincore;
Usage
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');
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.