Re: relfilenode

Lists: pgsql-hackers
From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: relfilenode
Date: 2005-10-28 01:12:15
Message-ID: 43617AEF.9060009@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


The docs have this description for pg_class::relfilenode: "Name of the
on-disk file of this relation; 0 if none". However, Elein just pointed
out to me that there are no entries with 0, so this description seems
incorrect. What should we say? It appears that in at least some of these
cases the value is the same as the oid.

cheers

andrew


From: elein <elein(at)varlena(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: relfilenode
Date: 2005-10-28 01:48:47
Message-ID: 20051028014847.GE26501@varlena.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Oct 27, 2005 at 09:12:15PM -0400, Andrew Dunstan wrote:
>
> The docs have this description for pg_class::relfilenode: "Name of the
> on-disk file of this relation; 0 if none". However, Elein just pointed
> out to me that there are no entries with 0, so this description seems
> incorrect. What should we say? It appears that in at least some of these
> cases the value is the same as the oid.
>
> cheers
>
> andrew
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
> choose an index scan if your joining column's datatypes do not
> match
>

I found that in my test db only pg_xactlock has a relfilenode == 0.
The sequences, tables and primary keys seem to have files in
PGDATA/base/* which correspond to the relfilenode.
However, views seem to have an oid I cannot correlate to anything.

So we need to say what 0 means and what the oid is for the views.

--elein
elein(at)varlena(dot)com


From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: relfilenode
Date: 2005-10-28 01:54:10
Message-ID: 20051028015410.GA77671@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Oct 27, 2005 at 09:12:15PM -0400, Andrew Dunstan wrote:
> The docs have this description for pg_class::relfilenode: "Name of the
> on-disk file of this relation; 0 if none". However, Elein just pointed
> out to me that there are no entries with 0, so this description seems
> incorrect. What should we say? It appears that in at least some of these
> cases the value is the same as the oid.

Is 0 a legitimate value now that pg_xactlock is gone? In pre-8.1
clusters that's the only relation I see with relfilenode 0, but
maybe that's just because I don't have anything defined that would
have relfilenode 0 (what, if anything, would?).

Composite types have relfilenode set even though they don't appear
to have an on-disk file -- should they be 0?

Based on what I've seen I've assumed that relfilenode starts out
the same as oid but can change if you do something that rewrites
the table (truncate, cluster, alter column type, etc.). I haven't
dug into the code to confirm that, though.

--
Michael Fuhr


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: relfilenode
Date: 2005-10-28 02:03:42
Message-ID: 25827.1130465022@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> The docs have this description for pg_class::relfilenode: "Name of the
> on-disk file of this relation; 0 if none". However, Elein just pointed
> out to me that there are no entries with 0, so this description seems
> incorrect. What should we say? It appears that in at least some of these
> cases the value is the same as the oid.

My opinion is that the documentation is right and the code is wrong ;-)
It's a bad idea to have valid-looking relfilenodes in entries that are
not describing real on-disk structures --- not least because such values
could by chance match on-disk files that actually exist, but belong to a
different pg_class entry.

This is probably just a matter of laziness somewhere in heap.c.

regards, tom lane