VACUUM FULL vs dropped columns

From: Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: VACUUM FULL vs dropped columns
Date: 2018-03-10 22:37:17
Message-ID: CAA8=A787gA=Ja0PMVyG9EdQVV-1t9+deK2Jd0PMLWNdppgzLHA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

While doing some testing I noticed this, which seems somewhat perverse:

create table t();
insert into t select from generate_series(1,10000);
select 'alter table t ' || string_agg(' add column c'||x::text||' int
default ' ||x::text,',')
from generate_series(1,1000) x \gexec

create table t_dropped();
insert into t_dropped select from generate_series(1,10000);
select 'alter table t_dropped ' || string_agg(' add column
c'||x::text||' int default ' ||x::text,',')
from generate_series(1,1000) x \gexec

alter table t_dropped drop column c900;

select pg_total_relation_size('t') as size_t,
pg_total_relation_size('t_dropped') as size_t_dropped;

size_t | size_t_dropped
----------+----------------
40960000 | 40960000
(1 row)

vacuum full t;
vacuum full t_dropped;

select pg_total_relation_size('t') as size_t,
pg_total_relation_size('t_dropped') as size_t_dropped;

size_t | size_t_dropped
----------+----------------
40960000 | 81920000
(1 row)

Why does VACUUM FULL cause the size of this table with a single
dropped column (1 out of 1000) cause the table size to double?

cheers

andrew

--
Andrew Dunstan https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2018-03-10 22:48:28 Intermittent pg_ctl failures on Windows
Previous Message Tomas Vondra 2018-03-10 21:29:47 Re: [HACKERS] PATCH: multivariate histograms and MCV lists