pg_relusage
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pg_relusage | 0.0.1 | STAT | PostgreSQL | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 6850 | pg_relusage | No | Yes | Yes | No | No | No | - |
| Related | pg_qualstats online_advisor hypopg pg_stat_statements index_advisor pg_stat_plans pg_upless pg_hint_plan pg_track_optimizer plan_filter |
|---|
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 0.0.1 | 1817161514 | pg_relusage | - |
| RPM | PIGSTY | 0.0.1 | 1817161514 | pg_relusage_$v | - |
| DEB | PIGSTY | 0.0.1 | 1817161514 | postgresql-$v-pg-relusage | - |
Build
You can build the RPM / DEB packages for pg_relusage using pig build:
Install
You can install pg_relusage directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
Install the extension using pig or apt/yum/dnf:
Preload:
Usage
pg_relusage hooks into the query executor and logs which relations (tables, views, indexes, etc.) are actually used by each SQL statement. Unlike the statement log, it reports relations after view expansion and unused join elimination.
How It Works
Once loaded, each SQL statement emits a log message listing all referenced relations:
Produces log output:
Loading
Configuration
| Parameter | Default | Description |
|---|---|---|
pg_relusage.log_level | LOG | Log level for relation messages |
pg_relusage.rel_kinds | 'riSvmfp' | Relation kinds to report (one-letter codes from pg_class.relkind) |
Relation kind codes: r = table, i = index, S = sequence, v = view, m = materialized view, f = foreign table, p = partitioned table.
Use Case
This extension is useful for discovering unused objects in legacy databases. By analyzing the logged relation usage over time, you can identify which tables, views, and indexes are actually accessed by your application.
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)