Re: FW: deleted records

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: "H(dot)J(dot) Sanders" <hjs(at)worldonline(dot)nl>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: FW: deleted records
Date: 2005-12-28 16:44:03
Message-ID: 20051228164403.GA29215@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Dec 28, 2005 at 02:15:24PM +0100, H.J. Sanders wrote:
> is there a way to find out how many deleted records there are in
> a table (this gives an indication that it is time to vacuum)?

Use the pgstattuple() function from contrib/pgstattuple.

test=> CREATE TABLE foo (x integer);
CREATE TABLE
test=> INSERT INTO foo SELECT 1 FROM generate_series(1, 10000);
INSERT 0 10000
test=> DELETE FROM foo WHERE random() < 0.5;
DELETE 4957
test=> \x
Expanded display is on.
test=> SELECT * FROM pgstattuple('foo');
-[ RECORD 1 ]------+-------
table_len | 368640
tuple_count | 5043
tuple_len | 161376
tuple_percent | 43.78
dead_tuple_count | 4957
dead_tuple_len | 158624
dead_tuple_percent | 43.03
free_space | 7736
free_percent | 2.1

--
Michael Fuhr

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Vivek Khera 2005-12-28 16:45:32 Re: just an inconvenience, or.... : failed queries don't appear in the log anymore since v8.?.?
Previous Message Ian Harding 2005-12-28 16:38:05 Re: WAL logs multiplexing?