vacuuming - doubt

Started by Jayadevan Mover 12 years ago3 messagesgeneral
Jump to latest
#1Jayadevan M
maymala.jayadevan@gmail.com

Hi,
Another theory question -
PostgreSQL documentation says that -
"There are two variants of VACUUM: standard VACUUM and VACUUM FULL. VACUUM
FULL can reclaim more disk space "
I created a table, inserted 1000 records and deleted them. The size after a
vacuum and a vacuum full are given -
select pg_total_relation_size('myt');;
pg_total_relation_size
------------------------
65536
(1 row)

accounts=> vacuum myt;
VACUUM

accounts=> select pg_total_relation_size('myt');;
pg_total_relation_size
------------------------
16384
(1 row)

accounts=> vacuum full myt;
VACUUM
accounts=> select pg_total_relation_size('myt');;
pg_total_relation_size
------------------------
0
(1 row)

So what was the 65536 bytes left behind after standard vacuum?

Regards,
Jayadevan

#2Scott Marlowe
scott.marlowe@gmail.com
In reply to: Jayadevan M (#1)
Re: vacuuming - doubt

On Wed, Dec 11, 2013 at 1:08 AM, Jayadevan M
<maymala.jayadevan@gmail.com> wrote:

Hi,
Another theory question -
PostgreSQL documentation says that -
"There are two variants of VACUUM: standard VACUUM and VACUUM FULL. VACUUM
FULL can reclaim more disk space "
I created a table, inserted 1000 records and deleted them. The size after a
vacuum and a vacuum full are given -
select pg_total_relation_size('myt');;
pg_total_relation_size
------------------------
65536
(1 row)

accounts=> vacuum myt;
VACUUM

accounts=> select pg_total_relation_size('myt');;
pg_total_relation_size
------------------------
16384
(1 row)

accounts=> vacuum full myt;
VACUUM
accounts=> select pg_total_relation_size('myt');;
pg_total_relation_size
------------------------
0
(1 row)

So what was the 65536 bytes left behind after standard vacuum?

30 second vacuum lesson:

regular vacuum marks empty space for re-use, and reclaims the empty
space at the end of a relation. So if the empty space is in the middle
etc it can't be reclaimed just reused.

vacuum full compacts a relation reclaiming all the empty space. It
requires an exclusive lock and is bad for production systems in
general because of this.

So the purpose of REGULAR vacuum is not to reclaim space from the
tables but to make it available for reuse later.
The purpose of vacuum FULL is to reclaim all wasted space at the
expense of an exclusive lock and db performance while it's happening.

So, since regular vacuum isn't designed to reclaim everything you
shouldn't be surprised that it did not, in fact, reclaim everything.
Try your experiment on larger datasets with more random deletions etc
to see the difference between regular and full vacuum.

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#3Jayadevan M
maymala.jayadevan@gmail.com
In reply to: Scott Marlowe (#2)
Re: vacuuming - doubt

Scott Marlowe-2 wrote

30 second vacuum lesson:

Thank you.

--
View this message in context: http://postgresql.1045698.n5.nabble.com/vacuuming-doubt-tp5782828p5783057.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general