pg_prewarm
prewarm relation data
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pg_prewarm | 1.2 | ADMIN | PostgreSQL | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 5890 | pg_prewarm | No | Yes | Yes | Yes | No | No | - |
| Related | pg_buffercache pgfincore pgcozy pg_cooldown |
|---|---|
| Depended By | pgcozy |
Version
| PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|
| 1.2 | 1.2 | 1.2 | 1.2 | 1.2 |
Install
Note: This is a built-in contrib extension of PostgreSQL
Usage
The pg_prewarm extension provides functions to load relation data into the operating system buffer cache or PostgreSQL buffer cache, reducing I/O latency for subsequent queries.
Prewarm a Relation
Function Signature
Returns the number of blocks prewarmed.
| Parameter | Description |
|---|---|
mode | prefetch (async OS), read (sync OS), or buffer (PG cache) |
fork | Relation fork to prewarm (e.g., main, fsm, vm) |
first_block | First block number (default: 0) |
last_block | Last block number (default: last block of relation) |
Autoprewarm
When loaded via shared_preload_libraries, autoprewarm periodically saves the list of buffers in the shared buffer cache to disk and restores them on restart.
GUC Parameters
| Parameter | Default | Description |
|---|---|---|
pg_prewarm.autoprewarm | true | Enable autoprewarm background worker |
pg_prewarm.autoprewarm_interval | 300s | Interval between autoprewarm.blocks file updates (0 = dump only at shutdown) |
Buffer state is saved to autoprewarm.blocks in the data directory. After restart, two background workers reload the saved buffers.
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)