Re: [XX000] ERROR: could not open relation with OID "someoid"

From: Igor Neyman <ineyman(at)perceptron(dot)com>
To: Artem Tomyuk <admin(at)leboutique(dot)com>, "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: [XX000] ERROR: could not open relation with OID "someoid"
Date: 2015-10-06 18:34:47
Message-ID: A76B25F2823E954C9E45E32FA49D70ECCD54E1D7@mail.corp.perceptron.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Hi.

When i running query (to find the total size of biggest relation in db):
https://wiki.postgresql.org/wiki/Disk_Usage

SELECT nspname || '.' || relname AS "relation",
pg_size_pretty(pg_total_relation_size(C.oid)) AS "total_size"
FROM pg_class C
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE nspname NOT IN ('pg_catalog', 'information_schema')
AND C.relkind <> 'i'
AND nspname !~ '^pg_toast'
ORDER BY pg_total_relation_size(C.oid) DESC
LIMIT 20;

I'am often getting the error [XX000] ERROR: could not open relation with OID "someoid". Every time the OID is different.
Some times the query succeeding and i see the result.
This also happens on the slave servers.

Any ideas?
Thank you.

PS
PostgreSQL 9.1.2 on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-11), 64-bit

If you want to exclude TOAST tables and indexes, instead of

AND C.relkind <> 'i'
AND nspname !~ '^pg_toast'

just do:

AND C.relkind = ‘r’ -- ordinary table

But, your error probably is caused by temporary tables, so to exclude those just add:

AND c.relpersistence != ‘t’

Regards,
Igor Neyman

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Jan 2015-10-06 22:59:02 Re: Long-running and non-finishing VACUUM ANALYZE on large table
Previous Message Artem Tomyuk 2015-10-06 18:04:05 [XX000] ERROR: could not open relation with OID "someoid"