Re: explaining the pg_total_relation_size/pg_relation_size results

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Wells Oliver <wells(dot)oliver(at)gmail(dot)com>
Cc: pgsql-admin <pgsql-admin(at)postgresql(dot)org>
Subject: Re: explaining the pg_total_relation_size/pg_relation_size results
Date: 2018-06-20 22:44:48
Message-ID: CAKFQuwYTfs75mqiQSAB8phgw35gHHUpoWMu-AAsCA9TGke1hFw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Wed, Jun 20, 2018 at 3:26 PM, Wells Oliver <wells(dot)oliver(at)gmail(dot)com>
wrote:

> I have the follwing in a view to glance at the size of my relations:
>
> pg_size_pretty(pg_relation_size(c.oid::regclass)) AS size,
> pg_total_relation_size(c.oid::regclass) AS bytes
>
> This view sorts by pg_relation_size(c.oid::regclass) descending.
>
> The question is: the byte values are often higher for relations with a
> lower size indicated by size. As I sit here, I see an 11GB table
> of 23821893632 bytes and a 12GB table of 14545387520 bytes, and
> lastly/weirdly, a 3194MB table of 19924844544 bytes.
>
> Can someone give me the quck explainer here of what I am looking at? I
> tend to trust the size more than the bytes but I want to understand both
> better.
>
> ​
https://www.postgresql.org/docs/10/static/functions-admin.html#FUNCTIONS-ADMIN-DBOBJECT

​The documented difference between the two size functions are "indexes" and
"toast" (and the non-main forks which are a small fraction of the
difference). Any observation of an inverse relationship between the two
doesn't seem actionable...

Toast is basically "automatic large object storage"; I leave the docs to
cover indexes.

David J.

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Amine Tengilimoglu 2018-06-21 07:26:52 Postgresql Conections Get Stuck on BIND and Server Don't Reboot
Previous Message Alvaro Herrera 2018-06-20 22:42:03 Re: explaining the pg_total_relation_size/pg_relation_size results