Обсуждение: [ADMIN] how to find a pg_toast table's primary table

Поиск
Список
Период
Сортировка

[ADMIN] how to find a pg_toast table's primary table

От
ProPAAS DBA
Дата:
Hi all;


I'm seeing this table as the most vacuumed table:


pg_toast.pg_toast_16784

How do I find the primary table for this toast table?



Thanks in advance



Re: [ADMIN] how to find a pg_toast table's primary table

От
"Joshua D. Drake"
Дата:
On 12/13/2016 03:24 PM, ProPAAS DBA wrote:
> Hi all;
>
>
> I'm seeing this table as the most vacuumed table:
>
>
> pg_toast.pg_toast_16784
>
> How do I find the primary table for this toast table?

Within the database:

select oid::regclass from pg_class where reltoastrelid='16784'::regclass;

JD;

--
Command Prompt, Inc.                  http://the.postgres.company/
                         +1-503-667-4564
PostgreSQL Centered full stack support, consulting and development.
Everyone appreciates your honesty, until you are honest with them.


Re: [ADMIN] how to find a pg_toast table's primary table

От
Jerry Sievers
Дата:
ProPAAS DBA <dba@propaas.com> writes:

> Hi all;
>
>
> I'm seeing this table as the most vacuumed table:
>
>
> pg_toast.pg_toast_16784
>
> How do I find the primary table for this toast table?

Find the pg_class row with reltoastrelid = $oid-of-toast-table.

HTH

>
>
>
> Thanks in advance

--
Jerry Sievers
Postgres DBA/Development Consulting
e: postgres.consulting@comcast.net
p: 312.241.7800


Re: [ADMIN] how to find a pg_toast table's primary table

От
Jorge Torralba
Дата:
select relname from pg_class where reltoastrelid = ( select oid from pg_class where relname = 'toast_table_name' );

On Tue, Dec 13, 2016 at 3:24 PM, ProPAAS DBA <dba@propaas.com> wrote:
Hi all;


I'm seeing this table as the most vacuumed table:


pg_toast.pg_toast_16784

How do I find the primary table for this toast table?



Thanks in advance



--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin



--
Thanks,

Jorge Torralba
----------------------------

Note: This communication may contain privileged or other confidential information. If you are not the intended recipient, please do not print, copy, retransmit, disseminate or otherwise use the information. Please indicate to the sender that you have received this email in error and delete the copy you received. Thank You.

Re: [ADMIN] how to find a pg_toast table's primary table

От
Tom Lane
Дата:
Jerry Sievers <gsievers19@comcast.net> writes:
> ProPAAS DBA <dba@propaas.com> writes:
>> pg_toast.pg_toast_16784
>> How do I find the primary table for this toast table?

> Find the pg_class row with reltoastrelid = $oid-of-toast-table.

After you've done that a couple of times, you'll notice that the numeric
part of the toast table's name is the OID of its parent, so really you
just need to do

select '16784'::regclass;

Confirming the reltoastrelid link is a good idea though.

            regards, tom lane