feat(t2): add storage parameters (reloptions) query#82
Merged
Conversation
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, |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Rebased version of #73 — adds new t2 query to audit objects with custom storage parameters.
What it shows
reloptionsChanges from original #73
--schemaalias renamed toschema_name(avoid reserved word)asfor table aliases per SQL style guideTesting
Supersedes #73
Closes #61