Re: Table size does not include toast size

From: Greg Smith <greg(at)2ndquadrant(dot)com>
To: Bernd Helmle <mailings(at)oopsware(dot)de>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Rafael Martinez <r(dot)m(dot)guerrero(at)usit(dot)uio(dot)no>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Table size does not include toast size
Date: 2009-12-21 16:30:31
Message-ID: 4B2FA2A7.3020004@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Bernd Helmle wrote:
> I've created a C-Function a while ago that extracts the TOAST size for
> a given relation. This gave me the opportunity to do a
> pg_relation_size(oid) + pg_relation_toast_size(oid) for a given table
> oid to calculate on disk data size required by a table. Maybe we
> should include such a function in core?

Writing such a thing is already on my to-do list; it's absolutely a
missing piece of the puzzle here. If you've got such a patch, by all
means submit that. I just ran into my first heavily TOASTy database
recently and the way I'm computing sizes on the relations there is too
complicated for my tastes, so it's completely unreasonable to expect
regular users to do that.

To answer Rafael's concerns directly: you're right that this is
confusing. pg_relation_size is always going to do what it does right
now just because of how that fits into the design of the database.
However, the documentation should be updated to warn against the issue
with TOAST here. And it should be easier to get the total you're like
to see here: main relation + toasted parts, since that's what most DBAs
want in this area.

--
Greg Smith 2ndQuadrant Baltimore, MD
PostgreSQL Training, Services and Support
greg(at)2ndQuadrant(dot)com www.2ndQuadrant.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2009-12-21 16:54:06 Re: Table size does not include toast size
Previous Message David E. Wheeler 2009-12-21 16:22:54 Re: Minimum perl version supported