Skip to content

fix(postgres): carry no size for a relation without storage of its own - #1945

Merged
cevheri merged 1 commit into
mainfrom
fix/postgres-view-size
Oct 24, 2026
Merged

cevheri merged 1 commit into
mainfrom
fix/postgres-view-size

Conversation

@cevheri

@cevheri cevheri commented Oct 24, 2026

Copy link
Copy Markdown
Member

The PostgreSQL listing reported sizeBytes: 0 for a plain view and for a partitioned table. PostgreSQL's pg_total_relation_size() answers 0 for a relation with no storage of its own. Studio documents 0 as a measured empty relation and an absent value as one it did not read, so a client drew "View · 0 B", as if the object were empty.

The listing now reads the size only for relkinds with storage, the list PostgreSQL's RELKIND_HAS_STORAGE() names: CASE WHEN c.relkind IN ('r', 'i', 'S', 't', 'm') THEN pg_total_relation_size(c.oid) END. The size-column repair for engines without that function, such as CockroachDB and Materialize, drops the guarded expression.

Measured through the repo provider on postgres:17.6-alpine:

Relation main this PR
plain view 0 absent
partitioned table (its partition held data) 0 absent
empty table 0 0
table, partition real size real size
materialized view, sequence real size real size

On CockroachDB v26.2.5 every kind still lists, through the repaired statement, with sizes absent on both main and this branch.

The provider test was written first and failed on main. docs/providers/postgres.md explains the rule. The two postgres.ts line numbers that object-route.ts cites are updated, and the test that pins them passes.

@codecov

codecov Bot commented Oct 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

The object listing read pg_total_relation_size for every relation kind, and that function answers 0 for a plain view and for a partitioned table, even when the partitions hold data. Studio reads 0 as a measured empty relation, so those rows claimed to be empty. The listing now reads the size only for a relkind with storage, the list RELKIND_HAS_STORAGE names, and the size repair for engines without the function drops the guarded expression. An empty table still carries 0, and a materialized view keeps its size.
@cevheri
cevheri force-pushed the fix/postgres-view-size branch from 2fcbb73 to d933e9b Compare October 24, 2026 00:52
@sonarqubecloud

Copy link
Copy Markdown

@cevheri
cevheri merged commit aa9cea3 into main Oct 24, 2026
39 checks passed
@cevheri
cevheri deleted the fix/postgres-view-size branch October 24, 2026 01:31
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.

1 participant