Re: Table size does not include toast size - Mailing list pgsql-hackers

From Greg Smith
Subject Re: Table size does not include toast size
Date
Msg-id 4B2FA2A7.3020004@2ndquadrant.com
Whole thread Raw
In response to Re: Table size does not include toast size  (Bernd Helmle <mailings@oopsware.de>)
Responses Re: Table size does not include toast size  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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@2ndQuadrant.com  www.2ndQuadrant.com



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Small Bug in GetConflictingVirtualXIDs
Next
From: Tom Lane
Date:
Subject: Re: Table size does not include toast size