Unix Technical Forum

Re: Convenient dump of table and object size in PG 7.4

This is a discussion on Re: Convenient dump of table and object size in PG 7.4 within the pgsql Admins forums, part of the PostgreSQL category; --> On Thu, May 26, 2005 at 09:39:26PM -0500, Steve Lane wrote: > Attached is a view I wrote for ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Admins

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-10-2008, 12:51 AM
Alvaro Herrera
 
Posts: n/a
Default Re: Convenient dump of table and object size in PG 7.4

On Thu, May 26, 2005 at 09:39:26PM -0500, Steve Lane wrote:

> Attached is a view I wrote for postgres 7.4 that seems to provide pretty
> accurate reporting of table sizes. For each non-system table in a database
> it shows base table size, size of any related TOAST data, and aggregate size
> of indexes.
>
> The code is somewhat ugly in that it contains a bunch of CASE statements the
> sole point of which is to transform the occasional NULL into a 0.
>
> Object sizes are computed from pg_class.relpages with an assumed page size
> of 8192.
>
> Comments and improvements most welcome.


You could change all those "CASE WHEN foo IS NULL THEN 0 ELSE foo" into
COALESCE(foo, 0).

Additionally, "show block_size" will give you the block (page) size. I
don't see how would you use that in a query though.

--
Alvaro Herrera (<alvherre[a]surnet.cl>)
"La tristeza es un muro entre dos jardines" (Khalil Gibran)

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-10-2008, 12:51 AM
Tom Lane
 
Posts: n/a
Default Re: Convenient dump of table and object size in PG 7.4

Alvaro Herrera <alvherre@surnet.cl> writes:
> On Thu, May 26, 2005 at 09:39:26PM -0500, Steve Lane wrote:
>> Object sizes are computed from pg_class.relpages with an assumed page size
>> of 8192.


> Additionally, "show block_size" will give you the block (page) size. I
> don't see how would you use that in a query though.


current_setting('block_size')

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:48 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com