Re: Quickly calculating row size of a table? - Mailing list pgsql-general

From Jared Evans
Subject Re: Quickly calculating row size of a table?
Date
Msg-id 1130253051.560395.41580@g44g2000cwa.googlegroups.com
Whole thread Raw
In response to Re: Quickly calculating row size of a table?  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Quickly calculating row size of a table?
List pgsql-general
Thanks very much for both your posts.

I tried both:

First, I performed a full vacuum on the entire database then

dbn=# SELECT relname, relpages*8192/reltuples from pg_class where
reltuples <> 0 and relname not like 'pg%';

atablename                |  2047.95

The first SQL statement gave me a rough idea of the tuple size while
the second SQL statement seemed to give out more details about the
table and its tuples.

dbn=# select 'atablename' as table_name, * from
pgstattuple('"public"."atablename"');

-[ RECORD 1 ]------+----------
table_name         | atablename
table_len          | 160137216
tuple_count        | 78194
tuple_len          | 129868251
tuple_percent      | 81.1
dead_tuple_count   | 0
dead_tuple_len     | 0
dead_tuple_percent | 0
free_space         | 29419740
free_percent       | 18.37

129868251 / 78194 = 1660.85

There's still a difference between the two reported tuple size of
atablename: 2047.95 - 1660.85 = 387.10

Can someone shed some more light on this and which one more closely
approximates the size of the tuples?

Jared


pgsql-general by date:

Previous
From: Zlatko Matić
Date:
Subject: Re: [ODBC] versions of oDBC driver
Next
From: Janning Vygen
Date:
Subject: Re: the best way to catch table modification