relpages of btree indexes are not truncating even after deleting allthe tuples from table and doing vacuum - Mailing list pgsql-hackers

From Mahendra Singh
Subject relpages of btree indexes are not truncating even after deleting allthe tuples from table and doing vacuum
Date
Msg-id CAKYtNAo80dd9Sc3PhQzucrbP2XyD122zs-cFbY=-7e+8pxzh1w@mail.gmail.com
Whole thread Raw
Responses Re: relpages of btree indexes are not truncating even after deletingall the tuples from table and doing vacuum  (Peter Geoghegan <pg@bowt.ie>)
List pgsql-hackers
Hi All,

While doing testing of "parallel vacuum" patch, I found that size of index relation is not reducing even after deleting all the tuples and firing vacuum command. I am not sure that this is expected behavior or not. For reference, below I am giving one example.

postgres=# create table test (a int);
CREATE TABLE
postgres=# create index indx1 on test (a);
CREATE INDEX
postgres=# insert into test (select a  from generate_series(1,100000) a);
INSERT 0 100000
postgres=# analyze ;
ANALYZE
postgres=# select relpages, relname from pg_class where relname = 'indx1';
 relpages | relname
----------+---------
      276 | indx1
(1 row)

-- delete all the tuples from table.
postgres=# delete from test ;
DELETE 100000

-- do vacuum to test tables
postgres=# vacuum test ;
VACUUM

-- check relpages in 'indx1' and 'test'
postgres=# select relpages, relname from pg_class where relname = 'indx1';
 relpages | relname
----------+---------
      276 | indx1
(1 row)

-- do vacuum to all the tables and check relpages in 'indx1'
postgres=# vacuum ;
VACUUM
postgres=# select relpages, relname from pg_class where relname = 'indx1';
 relpages | relname
----------+---------
      276 | indx1
(1 row)

-- check relpages in 'test' table
postgres=# select relpages, relname from pg_class where relname = 'test';
 relpages | relname
----------+---------
        0 | test
(1 row)


From above example, we can see that after deleting all the tuples from table and firing vacuum command, size of table is reduced but size of index relation is same as before vacuum.

Please let me your thoughts.

Thanks and Regards
Mahendra Singh Thalor
EnterpriseDB: http://www.enterprisedb.com



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: unsupportable composite type partition keys
Next
From: Alvaro Herrera
Date:
Subject: string literal continuations in C