Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eCZl1-000792-6Q for pgsql-general@arkaria.postgresql.org; Wed, 08 Nov 2017 23:27:43 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1eCZl0-0007lg-PH for pgsql-general@arkaria.postgresql.org; Wed, 08 Nov 2017 23:27:42 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eCZiY-00079c-DC for pgsql-general@postgresql.org; Wed, 08 Nov 2017 23:25:10 +0000 Received: from hogranch.com ([75.101.82.47]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1eCZiV-00055S-9D for pgsql-general@postgresql.org; Wed, 08 Nov 2017 23:25:09 +0000 Received: from [192.168.0.2] (porker [192.168.0.2]) by hogranch.com (8.11.6/8.11.6) with ESMTP id vA8NP0N17901 for ; Wed, 8 Nov 2017 15:25:00 -0800 Subject: Re: database size changed after restoring using pg_restore To: pgsql-general@postgresql.org References: From: John R Pierce Message-ID: <6ace5144-1c71-18fa-e1a2-2341bd28c23f@hogranch.com> Date: Wed, 8 Nov 2017 15:24:55 -0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------DD01AF2D1F9A4B96D55A9BE1" Content-Language: en-US X-HawgScanner-Information: Please contact the ISP for more information X-HawgScanner: Found to be clean List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org This is a multi-part message in MIME format. --------------DD01AF2D1F9A4B96D55A9BE1 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 11/8/2017 2:59 PM, Dylan Luong wrote: > > Hi > > I am upgrading some databases from a PostgreSQL 9.2 server to a new > PostgreSQL 9.6 server. > > I used pg_dump and pg_restore for the upgrade. > > ..... > > But when I listed the size of the database (postgres=# \l+) between > the 9.2 and the upgraded 9.6, they were different. > > on 9.2 it was 3776 MB > on 9.6 it was 1570 MB > > I also did a few more databases using the same steps and they all > appeared to be smaller. Is that normal? yes.  a freshly restored database will be all contiguous with no embedded free tuples left over from operations.   databases that get updates (or inserts/deletes) tend to bloat. -- john r pierce, recycling bits in santa cruz --------------DD01AF2D1F9A4B96D55A9BE1 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit
On 11/8/2017 2:59 PM, Dylan Luong wrote:

Hi

I am upgrading some databases from a PostgreSQL 9.2 server to a new PostgreSQL 9.6 server.

I used pg_dump and pg_restore for the upgrade. 

.....

But when I listed the size of the database (postgres=# \l+) between the 9.2 and the upgraded 9.6, they were different.

on 9.2 it was 3776 MB
on 9.6 it was 1570 MB

I also did a few more databases using the same steps and they all appeared to be smaller. Is that normal?


yes.  a freshly restored database will be all contiguous with no embedded free tuples left over from operations.   databases that get updates (or inserts/deletes) tend to bloat.


-- 
john r pierce, recycling bits in santa cruz
--------------DD01AF2D1F9A4B96D55A9BE1--