Thread: ERROR: could not open relation with OID 49152

ERROR: could not open relation with OID 49152

From
"Scott Marlowe"
Date:
OK, I'm getting the above error on one of my fairly new 8.3 production
databases.  It happens when I run a query to see the size of my
tables.

SELECT pg_relation_size(c.relfilenode), n.nspname AS schemaname,
c.relname AS tablename, pg_get_userbyid(c.relowner) AS tableowner,
t.spcname AS tablespace, c.relhasindex AS hasindexes, c.relhasrules AS
hasrules, c.reltriggers > 0 AS hastriggers
   FROM pg_class c
   LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
   LEFT JOIN pg_tablespace t ON t.oid = c.reltablespace
  WHERE n.nspname = 'public';
ERROR:  could not open relation with OID 49152

If I run this query:

SELECT c.relfilenode, n.nspna... same as the above after this...

I get this:

 relfilenode | schemaname |         tablename          | tableowner |
tablespace | hasindexes | hasrules | hastriggers
-------------+------------+----------------------------+------------+------------+------------+----------+-------------
       49956 | public     | paid_idx_pkey              | dgish      |
          | f          | f        | f
       49958 | public     | page_access_timestamp      | dgish      |
          | f          | f        | f
       49152 | public     | page_access                | dgish      |
          | t          | f        | f

and a few other lines editted out for brevity.

Any ideas what the cause of this is?  What part of my catalogs is borked?

Now, I can backup this db, and restore it with no errors, and the
error will go away.  Same query on the same dataset returns the right
number of rows and their size.

Re: ERROR: could not open relation with OID 49152

From
Tom Lane
Date:
"Scott Marlowe" <scott.marlowe@gmail.com> writes:
> OK, I'm getting the above error on one of my fairly new 8.3 production
> databases.  It happens when I run a query to see the size of my
> tables.

> SELECT pg_relation_size(c.relfilenode),

Pretty sure that should be c.oid.

            regards, tom lane

Re: ERROR: could not open relation with OID 49152

From
Alvaro Herrera
Date:
Scott Marlowe escribió:
> OK, I'm getting the above error on one of my fairly new 8.3 production
> databases.  It happens when I run a query to see the size of my
> tables.
>
> SELECT pg_relation_size(c.relfilenode), n.nspname AS schemaname,
> c.relname AS tablename, pg_get_userbyid(c.relowner) AS tableowner,
> t.spcname AS tablespace, c.relhasindex AS hasindexes, c.relhasrules AS
> hasrules, c.reltriggers > 0 AS hastriggers
>    FROM pg_class c
>    LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
>    LEFT JOIN pg_tablespace t ON t.oid = c.reltablespace
>   WHERE n.nspname = 'public';
> ERROR:  could not open relation with OID 49152

Try pg_relation_size(c.oid) instead.

--
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

Re: ERROR: could not open relation with OID 49152

From
"Scott Marlowe"
Date:
On Mon, Jul 21, 2008 at 6:07 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> "Scott Marlowe" <scott.marlowe@gmail.com> writes:
>> OK, I'm getting the above error on one of my fairly new 8.3 production
>> databases.  It happens when I run a query to see the size of my
>> tables.
>
>> SELECT pg_relation_size(c.relfilenode),
>
> Pretty sure that should be c.oid.

Thanks.  I'll slink away now...