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 1rrLJ8-0002zZ-Sn for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Apr 2024 17:18:55 +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 1rrLJ7-0002vb-8y for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Apr 2024 17:18:53 +0000 Received: from magus.postgresql.org ([87.238.57.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 1rrLJ6-0002vT-Ve for pgsql-hackers@lists.postgresql.org; Mon, 01 Apr 2024 17:18:53 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rrLJ5-0000kj-8p for pgsql-hackers@lists.postgresql.org; Mon, 01 Apr 2024 17:18:53 +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 431HIkGp1097773; Mon, 1 Apr 2024 13:18:46 -0400 From: Tom Lane To: Jeff Davis cc: Corey Huinker , Stephen Frost , Ashutosh Bapat , Matthias van de Meent , Peter Smith , PostgreSQL Hackers , Tomas Vondra Subject: Re: Statistics Import and Export In-reply-to: <57e2d0c87d30e9b0dfb80f5b5d6a1a82a2539f10.camel@j-davis.com> References: <54f190b6c757da2a33cce811949e9dd9601fcba7.camel@j-davis.com> <1632327b74a734f8c434eb75e824160d2b06a697.camel@j-davis.com> <16412b8b7ae443cb7470006beff3011927048860.camel@j-davis.com> <1b1bd1ec39ab3de09a17bf7b241021067e5bd63c.camel@j-davis.com> <2bce855db8259c5672a09f863a307ca07b967b68.camel@j-davis.com> <5e94c358caedf2a231dd71624c3578db7227a265.camel@j-davis.com> <4afa70edab849ff1623! ! 8d1100b6652404e9a4d9d.camel@j-davis.com> <3df03aa65aa6ea3a76582e1a792e422dc5c32ad3.camel@j-davis.com> <718fa933c2c58d0ecc61995ab5c7ca1fe78d6369.camel@j-davis.com> <447200.1711819134@sss.pgh.pa.us> <473884.1711820380@sss.pgh.pa.us> <581538.1711843736@sss.pgh.pa.us> <57e2d0c87d30e9b0dfb80f5b5d6a1a82a2539f10.camel@j-davis.com> Comments: In-reply-to Jeff Davis message dated "Mon, 01 Apr 2024 10:06:45 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <1097771.1711991926.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Mon, 01 Apr 2024 13:18:46 -0400 Message-ID: <1097772.1711991926@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Jeff Davis writes: > On Sat, 2024-03-30 at 20:08 -0400, Tom Lane wrote: >> I haven't looked at the details, but I'm really a bit surprised >> by Jeff's assertion that CREATE INDEX destroys statistics on the >> base table.  That seems wrong from here, and maybe something we >> could have it not do.  (I do realize that it recalculates reltuples >> and relpages, but so what?  If it updates those, the results should >> be perfectly accurate.) > In the v15 of the patch I was looking at, "pg_dump -s" included the > statistics. The stats appeared first in the dump, followed by the > CREATE INDEX commands. The latter overwrote the relpages/reltuples set > by the former. > While zeros are the right answers for a schema-only dump, it defeated > the purpose of including relpages/reltuples stats in the dump, and > caused the pg_upgrade TAP test to fail. > You're right that there are a number of ways this could be resolved -- > I don't think it's an inherent problem. I'm inclined to call it not a problem at all. While I do agree there are use-cases for injecting false statistics with these functions, I do not think that pg_dump has to cater to such use-cases. In any case, I remain of the opinion that stats are data and should not be included in a -s dump (with some sort of exception for pg_upgrade). If the data has been loaded, then a subsequent overwrite by CREATE INDEX should not be a problem. regards, tom lane