Re: Tablespace OID, database OID, relfilenode

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Wiwwo Staff <wiwwo(at)wiwwo(dot)com>, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Tablespace OID, database OID, relfilenode
Date: 2023-01-17 15:44:09
Message-ID: 3942b14b-be82-805f-3ec4-3be85d89b2b6@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 1/17/23 07:35, Wiwwo Staff wrote:
> Hi Laurenz,
> thanks for your answer!
> Ok, but I don't think "1663" is a sort of constant value for "base",
> isn't it?

From source:

backend/catalog/postgres.bki

open pg_tablespace
insert ( 1663 pg_default 10 _null_ _null_ )
insert ( 1664 pg_global 10 _null_ _null_ )

>
> Let me clarify my question: how do I get, with a query, from "base" to
> 1663 (or whatever the value is)?

select * from pg_tablespace ;
oid | spcname | spcowner | spcacl | spcoptions
------+------------+----------+--------+------------
1663 | pg_default | 10 | NULL | NULL
1664 | pg_global | 10 | NULL | NULL

>
> On Tue, Jan 17, 2023 at 4:01 PM Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at
> <mailto:laurenz(dot)albe(at)cybertec(dot)at>> wrote:
>
> On Tue, 2023-01-17 at 15:48 +0100, Wiwwo Staff wrote:
> > Quick and to the point:
> >
> > If i execute
> > select pg_relation_filepath('pgbench_accounts');
> >
> > I get
> >  pg_relation_filepath
> > ----------------------
> >  base/5/16398
> >
> > where "base" is tablespace, but not tablespace OID, nor
> tablespace name.
> > How do I link it to get from "base" the tablespace OID?
> >
> > Or, in other words, given table  pgbench_accounts, how do I get
> tablespace OID,
> > database OID and relfilenode so that I can use this info to
> filter output of pg_waldump?
>
> The tablespace OID is 1663, since "base" is the default tablespace
> "pg_default".
>
> Yours,
> Laurenz Albe
> --
> Cybertec | https://www.cybertec-postgresql.com
> <https://www.cybertec-postgresql.com>
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2023-01-17 18:05:58 Re: https://wiki.postgresql.org/wiki/Working_with_Git link one link cannot open, another link is unrelated.
Previous Message David G. Johnston 2023-01-17 15:43:30 Re: Tablespace OID, database OID, relfilenode