From: | Hans Schou <hans(dot)schou(at)gmail(dot)com> |
---|---|
To: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | wiki Disk Usage, table size: ERROR: could not open relation with OID 0 |
Date: | 2018-03-14 15:17:54 |
Message-ID: | CAApBw37QdLBn0bE=OykDnn1BUJmz_rDBHcs3bWfbTScQ6cDg3A@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi
I got the message
ERROR: could not open relation with OID 0
when running the "General Table Size Information" from
https://wiki.postgresql.org/wiki/Disk_Usage
This patch gives some system tables
@@ -12,5 +12,6 @@
FROM pg_class c
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE relkind = 'r'
+ AND reltoastrelid!=0
) a
) a;
But I guess it was supposed to give size of all tables.
I'm running version 9.1.9 so it should be working according to the wiki.
The original statement:
SELECT *, pg_size_pretty(total_bytes) AS total
, pg_size_pretty(index_bytes) AS INDEX
, pg_size_pretty(toast_bytes) AS toast
, pg_size_pretty(table_bytes) AS TABLE
FROM (
SELECT *, total_bytes-index_bytes-COALESCE(toast_bytes,0) AS
table_bytes FROM (
SELECT c.oid,nspname AS table_schema, relname AS TABLE_NAME
, c.reltuples AS row_estimate
, pg_total_relation_size(c.oid) AS total_bytes
, pg_indexes_size(c.oid) AS index_bytes
, pg_total_relation_size(reltoastrelid) AS toast_bytes
FROM pg_class c
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE relkind = 'r'
) a) a;
Any help much appreciated.
./best regards
From | Date | Subject | |
---|---|---|---|
Next Message | Adrian Klaver | 2018-03-14 15:44:11 | Re: JDBC connectivity issue |
Previous Message | chris | 2018-03-14 14:51:33 | Re: JDBC connectivity issue |