Re: dead tuple difference between pgstattuple and pg_stat_user_tables

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Matthew Tice <mjtice(at)gmail(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: dead tuple difference between pgstattuple and pg_stat_user_tables
Date: 2024-08-23 16:53:15
Message-ID: c8cd9d54-376f-42be-a394-52099dd3ca1f@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 8/23/24 09:51, Adrian Klaver wrote:
> On 8/23/24 09:33, Matthew Tice wrote:
>>
>>
>> On Fri, Aug 23, 2024 at 10:26 AM Adrian Klaver
>> <adrian(dot)klaver(at)aklaver(dot)com <mailto:adrian(dot)klaver(at)aklaver(dot)com>> wrote:
>
>>     https://www.postgresql.org/docs/current/pgstattuple.html
>>     <https://www.postgresql.org/docs/current/pgstattuple.html>
>>
>>     pgstattuple_approx(regclass) returns record
>>
>>           pgstattuple_approx is a faster alternative to pgstattuple that
>>     returns approximate results.
>>
>>     Not sure how you get exact count out of that?
>>
>>
>> Maybe the wording is a little confusing to me. Under the section
>> for pgstattuple_approx:
>> "pgstattuple_approx tries to avoid the full-table scan and returns
>> exact dead tuple statistics along with an approximation of the number
>> and size of live tuples and free space."
>
> Yeah, see what you mean.
>
> The part that bears more investigating for this case is:
>
> "It does this by skipping pages that have only visible tuples according
> to the visibility map (if a page has the corresponding VM bit set, then
> it is assumed to contain no dead tuples).
>
> Wondering if PostgreSQl-compatible covers this?

Meant to add:

What happens if you use pgstattuple instead?

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Koen De Groote 2024-08-23 19:31:51 Re: On a subscriber, why is last_msg_send_time in pg_stat_subscription sometimes null?
Previous Message Adrian Klaver 2024-08-23 16:51:17 Re: dead tuple difference between pgstattuple and pg_stat_user_tables