pg_mem_counters
pg_mem_counters · Maintains named total and requests-per-minute counters in PostgreSQL shared memory.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100434 | pg_mem_counters | pg_mem_counters | 1.0 | STAT | MIT | C |
PostgreSQL · 10, 11
Usage
Sources:
pg_mem_counters maintains named total-hit and requests-per-minute counters in PostgreSQL shared memory. It is useful for lightweight process-local instrumentation where durable, transactional accounting is not required.
The library must be preloaded and PostgreSQL restarted before the extension is created:
inc_mem_counter(counter,increment) adds to and returns the total; omitting the increment reads the total. get_mem_counter_rpm(counter) returns the recent per-minute count, and mem_counters() lists each name with its total and RPM value.
The state is held in shared memory, not in durable database tables, so do not use it for billing, audit, quotas, or any counter that must survive restart or participate in rollback. The reviewed README documents only PostgreSQL 10 and 11, and the control version is 1.0; test memory sizing, name cardinality, concurrency, restart behavior, and current-server ABI before deployment.