Re: Which files belong to which database?

Lists: pgsql-novice
From: Oliver Fromme <olli(at)lurza(dot)secnetix(dot)de>
To: pgsql-novice(at)postgresql(dot)org
Subject: Which files belong to which database?
Date: 2003-09-10 10:13:44
Message-ID: 200309101013.h8AADiWu078632@lurza.secnetix.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice


Hi,

Is there a way to find out which files in $PGDATA belong
to which database? I need that information for accounting
purposes (users are billed per Gbyte of data). In mysql
it is very easy, because the subdirectories have the same
names as the databases.

Thanks in advance!

Regards
Oliver

--
Oliver Fromme, secnetix GmbH & Co KG, Oettingenstr. 2, 80538 München
Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.

"C++ is to C as Lung Cancer is to Lung."
-- Thomas Funke


From: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
To: Oliver Fromme <olli(at)lurza(dot)secnetix(dot)de>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Which files belong to which database?
Date: 2003-09-10 10:49:27
Message-ID: 1063190966.5251.117.camel@linda.lfix.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

On Wed, 2003-09-10 at 11:13, Oliver Fromme wrote:
> Hi,
>
> Is there a way to find out which files in $PGDATA belong
> to which database? I need that information for accounting
> purposes (users are billed per Gbyte of data). In mysql
> it is very easy, because the subdirectories have the same
> names as the databases.

The subdirectories in $PGDATA/base are named by the database oid.

The contrib module, oid2name, can be used to retrieve the database
names.

--
Oliver Elphick Oliver(dot)Elphick(at)lfix(dot)co(dot)uk
Isle of Wight, UK http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
========================================
"Draw near to God and he will draw near to you.
Cleanse your hands, you sinners; and purify your
hearts, you double minded." James 4:8


From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Oliver Fromme <olli(at)lurza(dot)secnetix(dot)de>
Cc: <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Which files belong to which database?
Date: 2003-09-10 14:28:43
Message-ID: 20030910072538.F64012-100000@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice


On Wed, 10 Sep 2003, Oliver Fromme wrote:

> Is there a way to find out which files in $PGDATA belong
> to which database? I need that information for accounting
> purposes (users are billed per Gbyte of data). In mysql

I believe the structure in general is:
base/
base/<database oid>
base/<database oid>/<object relfilenoid>

In contrib there's a program, oid2name, which will show the name/number
mappings.