Re: \d+ not showing TOAST table size?

From: Josh Kupershmidt <schmiddy(at)gmail(dot)com>
To: Jon Nelson <jnelson+pgsql(at)jamponi(dot)net>
Cc: pgsql <pgsql-general(at)postgresql(dot)org>
Subject: Re: \d+ not showing TOAST table size?
Date: 2011-09-20 19:09:01
Message-ID: CAK3UJRFCM4JV2wdOeCTcXs0L3EBuEr9owsucJzNNZSTmBHE9CA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Sep 20, 2011 at 1:26 PM, Jon Nelson <jnelson+pgsql(at)jamponi(dot)net> wrote:
> I have a table with a fair bit of TOAST data in it.
> I noticed that \d+ does /not/ include that information (but
> pg_total_relation_size does).

I assume by "\d+" you meant "\dt+" (\d+ doesn't show sizes at all). On
version 9.0 and up, \dt+ uses pg_relation_size() internally, which
actually does include TOAST data as this comment in dbsize.c explains:

* Calculate total on-disk size of a given table,
* including FSM and VM, plus TOAST table if any.
* Indexes other than the TOAST table's index are not included.

The extra space displayed by pg_total_relation_size() is from indexes
on the table.

> Is that intentional? It seems a bit misleading, insofar as "\d+" feels
> like it is meant to be a rough indication of the table size, but if
> 90% of the data is in TOAST then the *real* data stored is much more
> than displayed.

FYI, the implementation was agreed upon here:
http://archives.postgresql.org/pgsql-hackers/2011-03/msg01268.php

There were some ideas tossed around in that thread about ways to also
include index size as well, which I do think would be nice to have. It
would be a challenge to format that information nicely, particularly
without messing up the tabular output of different types of relations
(e.g. "\dts+").

Josh

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2011-09-20 19:11:50 Re: \d+ not showing TOAST table size?
Previous Message Devrim GÜNDÜZ 2011-09-20 17:41:35 Re: upgrade postgres to 8.4.8, centos 5.3