Re: Doesn't PostgreSQL clean data in data file after delete records form table?

From: hubert depesz lubaczewski <depesz(at)depesz(dot)com>
To: zh1029 <zh1029(at)sina(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Doesn't PostgreSQL clean data in data file after delete records form table?
Date: 2016-03-23 10:33:25
Message-ID: 20160323103324.GC24410@depesz.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Mar 23, 2016 at 03:27:45AM -0700, zh1029 wrote:
> Hi,
> we are using PostgreSQL 9.3.6 version and observe data file size is not
> decreased after we deleted records from the table. It looks quite abnormal.
> Is it as PostreSQL designed?
>
> DBTestPostgres=# select count (*) from test_data ;
> 0
>
> # ls -l
> total 788932
> .............
> -rw------- 1 _nokfssystestpostgres root *801067008* Mar 23 17:51 32768

Yes, that's perfectly OK. It is due to MVCC mechanisms.

subsequent vacuum (at least in your case) should free the disk space,
and if it doesn't, check other ways, described here:
http://www.depesz.com/2011/07/06/bloat-happens/

Best regards,

depesz

--
The best thing about modern society is how easy it is to avoid contact with it.
http://depesz.com/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message mariusz 2016-03-23 11:30:47 Re: Including SQL files
Previous Message zh1029 2016-03-23 10:27:45 Doesn't PostgreSQL clean data in data file after delete records form table?