Re: psql \dt and table size

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Bernd Helmle <mailings(at)oopsware(dot)de>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: psql \dt and table size
Date: 2011-03-27 01:59:18
Message-ID: AANLkTi=8s4=mg09UqymER-ty3cyY0_Usgf7FdULRvK28@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Mar 26, 2011 at 9:42 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> On Wed, Mar 23, 2011 at 4:33 PM, Alvaro Herrera
> <alvherre(at)commandprompt(dot)com> wrote:
>> Excerpts from Robert Haas's message of mié mar 23 17:24:59 -0300 2011:
>>> On Mon, Mar 21, 2011 at 1:44 PM, Bernd Helmle <mailings(at)oopsware(dot)de> wrote:
>>> > It stroke me today again, that \dt+ isn't displaying the acurate table size
>>> > for tables, since it uses pg_relation_size() till now. With having
>>> > pg_table_size() since PostgreSQL 9.0 available, i believe it would be more
>>> > useful to have the total acquired storage displayed, including implicit
>>> > objects (the mentioned case where it was not very useful atm was a table
>>> > with a big TOAST table).
>>>
>>> I guess the threshold question for this patch is whether
>>> pg_table_size() is a "more accurate" table size or just a different
>>> one.
>>
>> Not including the toast table and index in the size is just plain wrong.
>> Reporting the size without the toast objects is an implementation
>> artifact that should not be done unless explicitely requested.
>
> It sounds like everyone is in agreement that we should go ahead and
> commit this patch, so I'll go do that.

Err, wait a minute. This can't be quite right: showTables isn't
mutually exclusive with other options; we don't want to display the
size using pg_relation_size() when someone says:

\dts

and pg_table_size() when they say:

\dt

and pg_relation_size() when they say:

\ds

But I think we can just call pg_table_size() regardless in 9.0+; I
believe it'll return the same results as pg_relation_size() on
non-tables. Anyone see a problem with that?

Also, for clarity, the 9.0+ code should go first, like this:

if (pset.sversion >= 90000)
{
/* do stuff */
}
else if (pset.sversion >= 81000
{
/* do different stuff */
}

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2011-03-27 02:19:20 Re: Typed-tables patch broke pg_upgrade
Previous Message Robert Haas 2011-03-27 01:42:53 Re: psql \dt and table size