Обсуждение: pgsql74_STATE.sh a script to facilitate operation of multiple backends / multiple binaries in highly available production environments

Поиск
Список
Период
Сортировка
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Verbose subject pretty much says it all. Depends on apache rotatelogs
for logging. Useful if you need to have a lot of backends or a lot of
different binaries, or both. Documented in inline comments.

- --
Andrew Hammond    416-673-4138    ahammond@ca.afilias.info
Database Administrator, Afilias Canada Corp.
CB83 2838 4B67 D40F D086 3568 81FC E7E5 27AF 4A9A
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)

iD8DBQFClM+/gfzn5SevSpoRAuVoAKC4dkp8BddoqtnEV8DwnY2g1umMJgCfcyca
XhyIebPTYa6q3Khu5NaigCo=
=f4PX
-----END PGP SIGNATURE-----

Вложения

Convenient dump of table and object size in PG 7.4

От
Steve Lane
Дата:
Hello all:

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.

-- sgl


--------
Steve Lane
Vice President
Soliant Consulting, Inc.
(312) 850-3830 (V)
(312) 850-3930 (F)
slane@soliantconsulting.com


Вложения

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

От
Alvaro Herrera
Дата:
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)

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

От
Tom Lane
Дата:
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


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

От
Tom Lane
Дата:
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