pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dave Crooke <dcrooke@gmail.com>
Cc: venu madhav <venutaurus539@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Obtaining the exact size of the database.
Date: Sun, 20 Jun 2010 11:34:41 -0400
Message-ID: <25289.1277048081@sss.pgh.pa.us> (raw)
In-Reply-To: <AANLkTim_d6FVYuCuXNS4YRTGYyQ7ixPMdfvfc9qM_CT6@mail.gmail.com>
References: <AANLkTimgNriCuf2QVmxUbqqiZO73BZ1VFMmaxq20RSKi@mail.gmail.com>
	<AANLkTim_d6FVYuCuXNS4YRTGYyQ7ixPMdfvfc9qM_CT6@mail.gmail.com>

Dave Crooke <dcrooke@gmail.com> writes:
> 4. If you're trying to figure out the net size of the table, i.e. how much
> free space is inside the table files for reuse by PG, then you need the
> pg_stat_tuple function ... this is built in to PG 8.4, and a plug-in
> activated by a script for PG 8.3, don't know if it exists in 8.1 or not.
> Like SELECT COUNT(*) this requires a full table scan.

I think what the OP actually wants is the number of live rows, so plain
old SELECT COUNT(*) would do it.  If that's too slow, a good alternative
is to ANALYZE the table and then look at its pg_class.reltuples entry
--- of course that will only be an approximate count.

			regards, tom lane



view thread (5+ messages)  latest in thread

Message-ID: <25289.1277048081@sss.pgh.pa.us>
Permalink:  ../25289.1277048081@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/25289.1277048081@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, dcrooke@gmail.com, venutaurus539@gmail.com
  Subject: Re: Obtaining the exact size of the database.
  In-Reply-To: <25289.1277048081@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox