Re: Which file belongs to which database?

Lists: pgsql-general
From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Which file belongs to which database?
Date: 2003-07-25 06:45:24
Message-ID: bfqjjt$2v2$1@main.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hello all,

just out of curiosity: how can I find out which files in the PG_DATA directory
belong to which database/table?

I have looked through the documentation of the system catalogs, but couldn't
find any reference to that.

The field datpath in pg_database is empty in my system (7.2 on Windows and 7.3.1
on Linux)

Cheers
Thomas


From: Karsten Hilbert <Karsten(dot)Hilbert(at)gmx(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Which file belongs to which database?
Date: 2003-07-25 07:07:54
Message-ID: 20030725090754.D967@hermes.hilbert.loc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

> just out of curiosity: how can I find out which files in the PG_DATA
> directory belong to which database/table?
>
> I have looked through the documentation of the system catalogs, but couldn't
you should also look through the mailing list archives...

Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346


From: "Shridhar Daithankar" <shridhar_daithankar(at)persistent(dot)co(dot)in>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Which file belongs to which database?
Date: 2003-07-25 07:12:14
Message-ID: 3F2125A6.5795.DF71AAF@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On 25 Jul 2003 at 8:45, Thomas Kellerer wrote:
> just out of curiosity: how can I find out which files in the PG_DATA directory
> belong to which database/table?

There is a contrib module oid2name. Use that.

You can just find the oid of the object from catalog and search for that file.
That's the principle.

Bye
Shridhar

--
But Captain -- the engines can't take this much longer!


From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Which file belongs to which database?
Date: 2003-07-25 07:30:20
Message-ID: bfqm80$gar$1@main.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Shridhar Daithankar schrieb:

> On 25 Jul 2003 at 8:45, Thomas Kellerer wrote:
>
>> just out of curiosity: how can I find out which files in the PG_DATA
>> directory belong to which database/table?
>
> There is a contrib module oid2name. Use that.
>
> You can just find the oid of the object from catalog and search for that
> file. That's the principle.
>
> Bye Shridhar
>

That easy ? :-)

Thanks for the information!

Cheers
Thomas


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Thomas Kellerer <spam_eater(at)gmx(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Which file belongs to which database?
Date: 2003-07-25 13:36:07
Message-ID: 7999.1059140167@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Thomas Kellerer <spam_eater(at)gmx(dot)net> writes:
> Shridhar Daithankar schrieb:
>> You can just find the oid of the object from catalog and search for that
>> file. That's the principle.

> That easy ? :-)

Actually you must look at pg_class.relfilenode; this is initially the
same as oid, but there are operations (such as cluster and reindex) that
assign new relfilenode values because they replace the underlying file.

At the database level, pg_database.oid is correct.

regards, tom lane