Re: table and index size

From: Curt Sampson <cjs(at)cynic(dot)net>
To: Damon Fasching <fasching(at)design(dot)lbl(dot)gov>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: table and index size
Date: 2002-07-15 07:53:14
Message-ID: Pine.NEB.4.44.0207151642140.497-100000@angelic.cynic.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, 15 Jul 2002, Damon Fasching wrote:

> Is there a way to determine the size of a table? an index?

The pg_class table has the size of every object in (usually 8K) pages. So:

SELECT relname, reltype, relpages, relpages / 128 AS MB
FROM pg_class
WHERE relname LIKE 'session%'

or whatever.

> I created a table with two int4 columns and inserted 100 K rows. The
> change in disk usage was only 4.3 KBytes, or .17 bits per integer.

Something's wrong there. Did you sync? 430 KB I'd believe.

> 1) Do these numbers seem reasonable to someone with a little more
> Postgresql experience?

No, they're completely out to lunch. ints are 4 bytes. postgres
row overhead is around about 40 bytes or so.

> One further question, if anyone can comment. I have the New Riders
> PostgreSQL Essential Reference book. It claims that in my database
> directory I should find some files with plain text names.

It's based on an old version of postgres. Now we use the object
IDs. So change the above query:

SELECT relname, reltype, relfilenode, relpages, relpages / 128 AS MB
FROM pg_class
WHERE relname LIKE 'session%'

cjs
--
Curt Sampson <cjs(at)cynic(dot)net> +81 90 7737 2974 http://www.netbsd.org
Don't you know, in this new Dark Age, we're all light. --XTC

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Sam Liddicott 2002-07-15 10:06:27 Re: 7.2.1 optimises very badly against 7.2
Previous Message Damon Fasching 2002-07-15 07:22:44 table and index size