Skip to content

feat(t2): add storage parameters (reloptions) query#82

Merged
NikolayS merged 1 commit intomasterfrom
feat/storage-parameters-query-rebased
Feb 10, 2026
Merged

feat(t2): add storage parameters (reloptions) query#82
NikolayS merged 1 commit intomasterfrom
feat/storage-parameters-query-rebased

Conversation

@NikolayS
Copy link
Copy Markdown
Owner

Summary

Rebased version of #73 — adds new t2 query to audit objects with custom storage parameters.

What it shows

  • All tables, indexes, materialized views with non-default reloptions
  • Object type, size, individual storage parameter settings
  • Partition relationships (shows parent table)
  • Warnings for potentially problematic settings:
    • ⚠️ Autovacuum disabled on tables > 10 MiB
    • Low fillfactor (< 50%)
    • Aggressive autovacuum (very low scale factor)

Changes from original #73

  • Fixed: header comment missing space after --
  • Fixed: fillfactor regex matched 50 but note said "< 50%" — now correctly matches only 10-49
  • Fixed: schema alias renamed to schema_name (avoid reserved word)
  • Fixed: added as for table aliases per SQL style guide
  • Fixed: missing newline at EOF
  • Fixed: start.psql no longer silently drops c1 (original PR was branched before c1 existed)

Testing

  • Tested locally on PostgreSQL 17
  • Verified fillfactor boundary: 49 → warning, 50 → no warning, 51 → no warning

Supersedes #73
Closes #61

Add new t2 query to list tables, indexes, and materialized views with
custom storage parameters. Helps DBAs:
- Audit custom table/index settings
- Find tables with disabled autovacuum
- Identify low fillfactor settings (< 50%)
- See partition relationships and their individual settings

Includes warnings for potentially problematic settings:
- Autovacuum disabled on tables > 10 MiB
- Low fillfactor (< 50%)
- Aggressive autovacuum (very low scale factor)

Closes #61
Comment on lines +16 to +17
c.reloptions,
unnest(c.reloptions) as option,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c.reloptions doesn’t look used outside the CTE (you already unnest() it). Dropping it avoids carrying the full array around.

Suggested change
c.reloptions,
unnest(c.reloptions) as option,
unnest(c.reloptions) as option,

Comment on lines +18 to +24
c.relispartition,
(select n2.nspname || '.' || c2.relname
from pg_inherits as inh
join pg_class as c2 on inh.inhparent = c2.oid
join pg_namespace as n2 on c2.relnamespace = n2.oid
where inh.inhrelid = c.oid
) as parent_table
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parent_table is only meaningful for partitions; computing this subquery for every row adds overhead, and on inherited (non-partition) tables it can error if multiple parents exist. Making it conditional (and adding a defensive limit 1) keeps the query robust.

Suggested change
c.relispartition,
(select n2.nspname || '.' || c2.relname
from pg_inherits as inh
join pg_class as c2 on inh.inhparent = c2.oid
join pg_namespace as n2 on c2.relnamespace = n2.oid
where inh.inhrelid = c.oid
) as parent_table
c.relispartition,
case
when c.relispartition then (
select
n2.nspname || '.' || c2.relname
from pg_inherits as inh
inner join pg_class as c2
on inh.inhparent = c2.oid
inner join pg_namespace as n2
on c2.relnamespace = n2.oid
where inh.inhrelid = c.oid
limit 1
)
else null
end as parent_table

@NikolayS NikolayS merged commit 40848ba into master Feb 10, 2026
6 checks passed
@NikolayS NikolayS deleted the feat/storage-parameters-query-rebased branch February 10, 2026 02:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: List reloptions

1 participant