Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dIgdZ-0008Ei-UV for pgsql-admin@arkaria.postgresql.org; Wed, 07 Jun 2017 19:29:02 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dIgdZ-0000mY-3O for pgsql-admin@arkaria.postgresql.org; Wed, 07 Jun 2017 19:29:01 +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 1dIgdY-0000mO-Ki for pgsql-admin@postgresql.org; Wed, 07 Jun 2017 19:29:00 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dIgdV-0002ln-Rg for pgsql-admin@postgresql.org; Wed, 07 Jun 2017 19:29:00 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v57JStwk014695; Wed, 7 Jun 2017 15:28:55 -0400 From: Tom Lane To: Harold Falkmeyer cc: pgsql-admin@postgresql.org Subject: Re: Restoring From Backups In-reply-to: References: Comments: In-reply-to Harold Falkmeyer message dated "Wed, 07 Jun 2017 12:09:26 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <14693.1496863735.1@sss.pgh.pa.us> Date: Wed, 07 Jun 2017 15:28:55 -0400 Message-ID: <14694.1496863735@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-admin Precedence: bulk Sender: pgsql-admin-owner@postgresql.org Harold Falkmeyer writes: > Three'ish more questions: > When restoring a table from backup (using pg_dump and pg_restore), are > there reasons, other than restoration performance, to defer index > restoration until after the COPY is complete? Mostly restoration performance: with standard btree indexes, creating an index over already-loaded data is faster than building the index incrementally. I do not think there's any benefit for GIN/GIST though; don't remember about hash. > After completing a COPY into a fresh table, is there any benefit to running > a subsequent VACUUM (given that there shouldn't be any dead tuples)? Yes, especially if you wait long enough for any transactions that were open during the COPY to go away. Then the VACUUM will mark pages all-visible, allowing index-only scans to work more efficiently. Even without that, it will set hint bits on committed tuples, removing that overhead from foreground queries. (But any other full-table scan, eg CREATE INDEX, also accomplishes the latter.) > As we understand it, an ANALYZE is necessary, regardless if we restore to a > table with preexisting indexes or one that's had indexes added after the > fact. Is this correct? Put slightly a different way, do CREATE INDEX > and/or REINDEX operations cause stats updates? Yes, you want to ANALYZE. CREATE INDEX will update the system's notion of the number of rows in the table, but not any of the more detailed stats gathered by ANALYZE (ie, what you can see in pg_stats). In most cases you'll need those stats to get decent plans for any but the most trivial queries. regards, tom lane -- Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-admin