Re: Get table total page quantity and cached page quantity

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: otar shavadze <oshavadze(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Get table total page quantity and cached page quantity
Date: 2021-08-15 20:31:37
Message-ID: CAApHDvodRrT7ePpW8Mvj28+b=jbG-7g3O638Y6Hjfx7dWsaGYQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, 15 Aug 2021 at 23:41, otar shavadze <oshavadze(at)gmail(dot)com> wrote:
> SELECT
> (SELECT relpages FROM pg_class where oid = 'public.my_table'::regclass::oid ) AS table_pages_quantity_total,
> (SELECT COUNT(DISTINCT relblocknumber) FROM pg_buffercache WHERE relfilenode = (
> SELECT relfilenode FROM pg_class WHERE oid = 'public.my_table'::regclass::oid -- (SELECT rel_oid FROM my_cte)
> ) ) AS table_pages_quantity_in_cache;
>
> This shows that table have only one page, while second column shows 3 unique pages in buffer cache. Seems I'm measuring those numbers incorrectly(?) can you please help, which column is incorrect (or may be both) ?

This question likely is more suited to the pgsql-general mailing list.
My answer in [1] likely will clear this up for you.

If you need further information, please ask on that thread.

David

[1] https://www.postgresql.org/message-id/CAApHDvpHddfoZOviYXiz2dCr9emrrbnJ7n3HkS8KNsD9W1wscA@mail.gmail.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2021-08-15 20:34:44 Re: Added schema level support for publication.
Previous Message Masahiko Sawada 2021-08-15 20:24:01 Re: Skipping logical replication transactions on subscriber side