pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Tablespace OID, database OID, relfilenode
7+ messages / 4 participants
[nested] [flat]

* Tablespace OID, database OID, relfilenode
@ 2023-01-17 14:48  Wiwwo Staff <wiwwo@wiwwo.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Wiwwo Staff @ 2023-01-17 14:48 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

Hi!
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?

Thanks a ton!

^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Tablespace OID, database OID, relfilenode
@ 2023-01-17 15:01  Laurenz Albe <laurenz.albe@cybertec.at>
  parent: Wiwwo Staff <wiwwo@wiwwo.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Laurenz Albe @ 2023-01-17 15:01 UTC (permalink / raw)
  To: Wiwwo Staff <wiwwo@wiwwo.com>; pgsql-general@lists.postgresql.org

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





^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Tablespace OID, database OID, relfilenode
@ 2023-01-17 15:35  Wiwwo Staff <wiwwo@wiwwo.com>
  parent: Laurenz Albe <laurenz.albe@cybertec.at>
  0 siblings, 2 replies; 7+ messages in thread

From: Wiwwo Staff @ 2023-01-17 15:35 UTC (permalink / raw)
  To: Laurenz Albe <laurenz.albe@cybertec.at>; +Cc: pgsql-general@lists.postgresql.org

Hi Laurenz,
thanks for your answer!
Ok, but I don't think "1663" is a sort of constant value for "base", isn't
it?

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

On Tue, Jan 17, 2023 at 4:01 PM Laurenz Albe <laurenz.albe@cybertec.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
>

^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Tablespace OID, database OID, relfilenode
@ 2023-01-17 15:43  David G. Johnston <david.g.johnston@gmail.com>
  parent: Wiwwo Staff <wiwwo@wiwwo.com>
  1 sibling, 0 replies; 7+ messages in thread

From: David G. Johnston @ 2023-01-17 15:43 UTC (permalink / raw)
  To: Wiwwo Staff <wiwwo@wiwwo.com>; +Cc: Laurenz Albe <laurenz.albe@cybertec.at>; pgsql-general@lists.postgresql.org

On Tue, Jan 17, 2023 at 8:36 AM Wiwwo Staff <wiwwo@wiwwo.com> 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?
>
> Let me clarify my question: how do I get, with a query, from "base" to
> 1663 (or whatever the value is)?
>
>>
>>
The system itself just uses an IF block...

https://github.com/postgres/postgres/search?q=DEFAULTTABLESPACE_OID

David J.

^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Tablespace OID, database OID, relfilenode
@ 2023-01-17 15:44  Adrian Klaver <adrian.klaver@aklaver.com>
  parent: Wiwwo Staff <wiwwo@wiwwo.com>
  1 sibling, 1 reply; 7+ messages in thread

From: Adrian Klaver @ 2023-01-17 15:44 UTC (permalink / raw)
  To: Wiwwo Staff <wiwwo@wiwwo.com>; Laurenz Albe <laurenz.albe@cybertec.at>; +Cc: pgsql-general@lists.postgresql.org

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.albe@cybertec.at 
> <mailto:laurenz.albe@cybertec.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.klaver@aklaver.com






^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Tablespace OID, database OID, relfilenode
@ 2023-01-17 19:49  Wiwwo Staff <wiwwo@wiwwo.com>
  parent: Adrian Klaver <adrian.klaver@aklaver.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Wiwwo Staff @ 2023-01-17 19:49 UTC (permalink / raw)
  To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: Laurenz Albe <laurenz.albe@cybertec.at>; pgsql-general@lists.postgresql.org

Thank you Adrian, thank you David!
So, it turns out, it *is* indeed an arbitrary constant...
I have been answered many times RTFM, it is actually the first time I have
being answered RTF source code.
(I searched for 1663 in PG docs, it is there, although not really
"intuitive").

Allow me to humbly propose to maybe at least write somewhere in the DOCs in
a clear way: "This is a number you should know, and it is arbitrary, and in
some functions it will be represented as 'base'  ".
It is fundamental to know this when one uses pg_waldump, for example.

Not to start a flame war here, just humbly proposing...

Thanks all again!


On Tue, Jan 17, 2023 at 4:44 PM Adrian Klaver <adrian.klaver@aklaver.com>
wrote:

> 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.albe@cybertec.at
> > <mailto:laurenz.albe@cybertec.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.klaver@aklaver.com
>
>

^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Tablespace OID, database OID, relfilenode
@ 2023-01-18 05:27  Adrian Klaver <adrian.klaver@aklaver.com>
  parent: Wiwwo Staff <wiwwo@wiwwo.com>
  0 siblings, 0 replies; 7+ messages in thread

From: Adrian Klaver @ 2023-01-18 05:27 UTC (permalink / raw)
  To: Wiwwo Staff <wiwwo@wiwwo.com>; +Cc: Laurenz Albe <laurenz.albe@cybertec.at>; pgsql-general@lists.postgresql.org

On 1/17/23 11:49, Wiwwo Staff wrote:
> Thank you Adrian, thank you David!
> So, it turns out, it *is* indeed an arbitrary constant...
> I have been answered many times RTFM, it is actually the first time I 
> have being answered RTF source code.
> (I searched for 1663 in PG docs, it is there, although not really 
> "intuitive").
> 
> Allow me to humbly propose to maybe at least write somewhere in the DOCs 
> in a clear way: "This is a number you should know, and it is arbitrary, 
> and in some functions it will be represented as 'base'  ".
> It is fundamental to know this when one uses pg_waldump, for example.
> 
> Not to start a flame war here, just humbly proposing...

https://www.postgresql.org/docs/current/storage-file-layout.html

"The pg_default tablespace is not accessed through pg_tblspc, but 
corresponds to PGDATA/base. Similarly, the pg_global tablespace is not 
accessed through pg_tblspc, but corresponds to PGDATA/global."

> 
> Thanks all again!
> 
> 

-- 
Adrian Klaver
adrian.klaver@aklaver.com






^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2023-01-18 05:27 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-01-17 14:48 Tablespace OID, database OID, relfilenode Wiwwo Staff <wiwwo@wiwwo.com>
2023-01-17 15:01 ` Laurenz Albe <laurenz.albe@cybertec.at>
2023-01-17 15:35   ` Wiwwo Staff <wiwwo@wiwwo.com>
2023-01-17 15:43     ` David G. Johnston <david.g.johnston@gmail.com>
2023-01-17 15:44     ` Adrian Klaver <adrian.klaver@aklaver.com>
2023-01-17 19:49       ` Wiwwo Staff <wiwwo@wiwwo.com>
2023-01-18 05:27         ` Adrian Klaver <adrian.klaver@aklaver.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox