pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andy Lester <andy@petdance.com>
To: pgsql-bugs@postgresql.org
Subject: BUG #5932: CLUSTER doesn't update n_dead_tup
Date: Tue, 15 Mar 2011 22:23:14 GMT
Message-ID: <201103152223.p2FMNEZC035008@wwwmaster.postgresql.org> (raw)


The following bug has been logged online:

Bug reference:      5932
Logged by:          Andy Lester
Email address:      andy@petdance.com
PostgreSQL version: 9.0
Operating system:   Linux
Description:        CLUSTER doesn't update n_dead_tup
Details: 

The CLUSTER command does not update the results coming back from
pg_stat_get_dead_tuples().

Running a VACUUM VERBOSE on the table after CLUSTERing shows that no tuples
are removed by the VACUUM, and the pg_stat_get_dead_tuples() then correctly
returns 0.

Here is a test program and its output that demonstrates.

$ cat cluster-bug.sql
drop table if exists foo;
create table foo ( x integer );

insert into foo values ( 1 );
insert into foo values ( 2 );
insert into foo values ( 3 );

create index foo_foo on foo(x);
cluster foo using foo_foo;

select pg_sleep(1);
select pg_stat_get_dead_tuples( 'foo'::regclass ), 'After 1st cluster,
before delete';

delete from foo where x = 2;

select pg_sleep(1);
select pg_stat_get_dead_tuples( 'foo'::regclass ), 'After delete, before 2nd
cluster, should have 1 dead row';

cluster foo;

select pg_sleep(1);
select pg_stat_get_dead_tuples( 'foo'::regclass ), 'After 2nd cluster,
before vacuum, should have 0 dead rows';

vacuum verbose foo;

select pg_sleep(1);
select pg_stat_get_dead_tuples( 'foo'::regclass ), 'After vacuum, should
still have 0 dead rows';


$ psql -X -f cluster-bug.sql
DROP TABLE
CREATE TABLE
INSERT 0 1
INSERT 0 1
INSERT 0 1
CREATE INDEX
CLUSTER
 pg_sleep 
----------
 
(1 row)

 pg_stat_get_dead_tuples |             ?column?             
-------------------------+----------------------------------
                       0 | After 1st cluster, before delete
(1 row)

DELETE 1
 pg_sleep 
----------
 
(1 row)

 pg_stat_get_dead_tuples |                         ?column?                 
       
-------------------------+--------------------------------------------------
--------
                       1 | After delete, before 2nd cluster, should have 1
dead row
(1 row)

CLUSTER
 pg_sleep 
----------
 
(1 row)

 pg_stat_get_dead_tuples |                         ?column?                 
        
-------------------------+--------------------------------------------------
---------
                       1 | After 2nd cluster, before vacuum, should have 0
dead rows
(1 row)

psql:cluster-bug.sql:24: INFO:  vacuuming "public.foo"
psql:cluster-bug.sql:24: INFO:  index "foo_foo" now contains 2 row versions
in 2 pages
DETAIL:  0 index row versions were removed.
0 index pages have been deleted, 0 are currently reusable.
CPU 0.00s/0.00u sec elapsed 0.00 sec.
psql:cluster-bug.sql:24: INFO:  "foo": found 0 removable, 2 nonremovable row
versions in 1 out of 1 pages
DETAIL:  0 dead row versions cannot be removed yet.
There were 0 unused item pointers.
0 pages are entirely empty.
CPU 0.00s/0.00u sec elapsed 0.00 sec.
VACUUM
 pg_sleep 
----------
 
(1 row)

 pg_stat_get_dead_tuples |                  ?column?                   
-------------------------+---------------------------------------------
                       0 | After vacuum, should still have 0 dead rows
(1 row)



view thread (6+ messages)  latest in thread

Message-ID: <201103152223.p2FMNEZC035008@wwwmaster.postgresql.org>
Permalink:  ../201103152223.p2FMNEZC035008@wwwmaster.postgresql.org/
Also on:    postgresql.org/message-id/201103152223.p2FMNEZC035008@wwwmaster.postgresql.org

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: andy@petdance.com
  Subject: Re: BUG #5932: CLUSTER doesn't update n_dead_tup
  In-Reply-To: <201103152223.p2FMNEZC035008@wwwmaster.postgresql.org>
  References: <201103152223.p2FMNEZC035008@wwwmaster.postgresql.org>

* 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