Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r7mEa-006kNP-E2 for pgsql-admin@arkaria.postgresql.org; Tue, 28 Nov 2023 00:45:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1r7mEZ-000xvb-57 for pgsql-admin@arkaria.postgresql.org; Tue, 28 Nov 2023 00:45:51 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r7mEY-000xv7-I5 for pgsql-admin@lists.postgresql.org; Tue, 28 Nov 2023 00:45:50 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r7mEW-007gbe-45 for pgsql-admin@postgresql.org; Tue, 28 Nov 2023 00:45:49 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 3AS0jj5b4040679; Mon, 27 Nov 2023 19:45:45 -0500 From: Tom Lane To: Murthy Nunna cc: "pgsql-admin@postgresql.org" Subject: Re: pg_dump -Are statistics saved? In-reply-to: References: Comments: In-reply-to Murthy Nunna message dated "Tue, 28 Nov 2023 00:28:05 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4040677.1701132345.1@sss.pgh.pa.us> Date: Mon, 27 Nov 2023 19:45:45 -0500 Message-ID: <4040678.1701132345@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Murthy Nunna writes: > The pg_dump (used verbose) log said "pg_dump: reading extended statistics". > Does it mean it saved statistics and they can be restored with pg_restore? What that means is that it will output clones of any CREATE STATISTICS commands you may have issued. > If not, is it necessary to run ANALYZE after pg_restore? That has always been necessary after a dump/restore, and still is. The pg_dump man page makes this clear enough, I should think: The dump file produced by pg_dump does not contain the statistics used by the optimizer to make query planning decisions. Therefore, it is wise to run ANALYZE after restoring from a dump file to ensure optimal performance; see Section 25.1.3 and Section 25.1.6 for more information. regards, tom lane