Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nnFi1-0005z5-Vt for pgsql-general@arkaria.postgresql.org; Sat, 07 May 2022 08:22:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nnFh2-0004Qz-Hv for pgsql-general@arkaria.postgresql.org; Sat, 07 May 2022 08:21:36 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nnFh2-0004Qp-5z for pgsql-general@lists.postgresql.org; Sat, 07 May 2022 08:21:36 +0000 Received: from mail-oi1-x22f.google.com ([2607:f8b0:4864:20::22f]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nnFh0-0003OC-II for pgsql-general@lists.postgresql.org; Sat, 07 May 2022 08:21:35 +0000 Received: by mail-oi1-x22f.google.com with SMTP id l16so9989577oil.6 for ; Sat, 07 May 2022 01:21:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to; bh=+taoAj5ZaP9Imyz04nkvSGY93Y1Zg0ZoEPNLSXteYfU=; b=Qw6IkuEdzCj+P+hMHAHqhr0M9gd3B60caWqANNrrrLZsx4I3Ngr1Nvb/dOXN1DI/i8 nLhaEnO7CDZDcbTkQoLJpqjijKKNw0HafgahHOOMhAj5HFX5d19Z9id7UM03oub5nZb7 ebDiJT9hA+usrrjfM6k9jo71oQ4eEFF6Qm4b8dMkdUWvWtfUcs8iICmoU4OjYghS/G6a +7keZEx8YEWzaqTZnM5OxSVZ/uIGhScvMXGj7e56QKjurpebhJrsNThHXKHfawxoe621 IANYZxy0S+/6mKK/vih2k3h3yJ9QjuFvr+4K7N4uIZaZ8pBPnbJ2I9QiJsO3PWiDQVVH Z7lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to; bh=+taoAj5ZaP9Imyz04nkvSGY93Y1Zg0ZoEPNLSXteYfU=; b=cWsho/22bAhnnVF23UqVsPA8/msu55vOowzvp3Avx5ZZEwuLr0t4m3Vl+cFF0c/FIX tiHnExRyK0ul4UHYXFg08zFTW0CecxEMMx83rVOSbVCiMzDxbrXrEqEs3Yl4pDLYNpmj XSnR0z6vxcD4RyaIMcagDifY4hyirxgcmiH8QXte+x+MSZPKKNKyIFcyslpRQiOLI5MC 5RVAOkEOzxGG+bRi7DMdFjr0WXmBudrwXXtY0k2tqo6WANwrlf2N+JTeX8aYE7WQNPJt stIsdJRQW0pN7+EH4DRgzQ+WxjFikNxZkU+Hoy5/wvPHDfOkKCuJeZQnBwksY8dYIGw6 6b1A== X-Gm-Message-State: AOAM531OyOUeEl7agZZDtx98mJXWUXvowzDQJjVEfQqCdJ2wB8pjtGPQ ktTImijzke2URJ9HZ2Y6oc7jLfvcG4k= X-Google-Smtp-Source: ABdhPJw5mr61mpsfR5ZQUEG6H0kMGVFEZioIxfYevWNXqSAaQgEhvVkfU9opQI/anve7Yro0pdip5w== X-Received: by 2002:a05:6808:1187:b0:322:2756:e23b with SMTP id j7-20020a056808118700b003222756e23bmr3403228oil.211.1651911692185; Sat, 07 May 2022 01:21:32 -0700 (PDT) Received: from [192.168.88.10] (ip68-11-68-85.no.no.cox.net. [68.11.68.85]) by smtp.googlemail.com with ESMTPSA id o2-20020a056820040200b0035eb4e5a6bbsm2778901oou.17.2022.05.07.01.21.31 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 07 May 2022 01:21:31 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------dRAPQ0LPtCZ7ZmlpLtg7hCRy" Message-ID: <3336352b-f97a-86e3-585b-207a98f56d4d@gmail.com> Date: Sat, 7 May 2022 03:21:30 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: Re: pg_dump: VACUUM and REINDEXING Content-Language: en-US To: pgsql-general@lists.postgresql.org References: From: Ron In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------dRAPQ0LPtCZ7ZmlpLtg7hCRy Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 5/6/22 21:35, Hasan Marzooq wrote: > Hello! > > I've some questions around Backup & Restore. > > 1: Is it necessary to perform a VACUUM and REINDEXING operation after > restoring the dump from Postgres 9.6 to Postgres 13? The dump size could > be 1/2 TB to 1 TB. Perform VACUUM after there have been many updates and deletes. There have been zero updates and deleted after pg_restore; therefore, *no need to vacuum*. pg_restore loads all tables and then builds all indices.  Thus, *no need to reindex*. > > 2: Also, are there any other operations that are recommended to perform > after pg_restore? ANALYZE all tables. https://www.postgresql.org/docs/13/app-vacuumdb.html vacuumdb --dbname=whatever --jobs=`nproc` --analyze-only > > 3: What is the minimum required disk space if taking a dump on the same > machine where the source database exists? Is it the "size of the current > data folder x 2"? Probably much less, but maybe (if, for example, you store lots of images (JPEG, TIFF, PDF, etc) in bytea columns. Whatever you do, make sure to run pg_dump with these options: --format=directory --jobs=`nproc` https://www.postgresql.org/docs/13/app-pgdump.html -- Angular momentum makes the world go 'round. --------------dRAPQ0LPtCZ7ZmlpLtg7hCRy Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit On 5/6/22 21:35, Hasan Marzooq wrote:
Hello!

I've some questions around Backup & Restore.

1: Is it necessary to perform a VACUUM and REINDEXING operation after restoring the dump from Postgres 9.6 to Postgres 13? The dump size could be 1/2 TB to 1 TB.

Perform VACUUM after there have been many updates and deletes.  There have been zero updates and deleted after pg_restore; therefore, no need to vacuum.

pg_restore loads all tables and then builds all indices.  Thus, no need to reindex.


2: Also, are there any other operations that are recommended to perform after pg_restore?

ANALYZE all tables.

https://www.postgresql.org/docs/13/app-vacuumdb.html

vacuumdb --dbname=whatever --jobs=`nproc` --analyze-only


3: What is the minimum required disk space if taking a dump on the same machine where the source database exists? Is it the "size of the current data folder x 2"?

Probably much less, but maybe (if, for example, you store lots of images (JPEG, TIFF, PDF, etc) in bytea columns.

Whatever you do, make sure to run pg_dump with these options: --format=directory --jobs=`nproc`
https://www.postgresql.org/docs/13/app-pgdump.html

--
Angular momentum makes the world go 'round.
--------------dRAPQ0LPtCZ7ZmlpLtg7hCRy--