Greg Smith <greg@2ndquadrant.com> writes:
> Florian Weimer wrote:
>> The sizes displayed by \dt+ in version 8.4.2 do not take TOAST tables
>> into account, presumably because the pg_relation_size does not reflect
>> that, either. I think this is a bit surprising. From a user
>> perspective, these are part of the table storage (I understand that
>> the indices might be a different story, but TOAST table are a fairly
>> deep implementation detail and should perhaps be hidden here).
> As of last week there's a new pg_table_size available that does what you
> want here:
> http://archives.postgresql.org/pgsql-committers/2010-01/msg00288.php
> I don't believe \dt+ has been updated yet to use that though; that's
> worth considering for a minute, not sure anybody thought about it yet.
We could only use pg_table_size against a backend >= 9.0, which would
mean that the displayed results mean something different depending on
which backend version psql is being used with. That's not necessarily
a deal-breaker, but it does seem a bit evil.
An alternative worth thinking about is to make it use
pg_total_relation_size instead of pg_relation_size. That's available,
with similar semantics, in all versions that have pg_relation_size
either (ie, >= 8.1). Also, this is arguably more nearly the right thing
since at the level of \dt+ I think people would expect indexes to get
folded in too.
regards, tom lane