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 1uFEQ0-001tOv-9T for pgsql-hackers@arkaria.postgresql.org; Wed, 14 May 2025 15:53:16 +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 1uFEPz-00AG0m-80 for pgsql-hackers@arkaria.postgresql.org; Wed, 14 May 2025 15:53:15 +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 1uFEPy-00AFz9-S8 for pgsql-hackers@lists.postgresql.org; Wed, 14 May 2025 15:53:14 +0000 Received: from mail-qt1-x832.google.com ([2607:f8b0:4864:20::832]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uFEPw-001mDF-0b for pgsql-hackers@lists.postgresql.org; Wed, 14 May 2025 15:53:13 +0000 Received: by mail-qt1-x832.google.com with SMTP id d75a77b69052e-476ae781d21so81967921cf.3 for ; Wed, 14 May 2025 08:53:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747237992; x=1747842792; darn=lists.postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=vGV5dcV3NTwmmW1H5TozP8u9urhrkwXe6SnuhWSBrAg=; b=MTjies/BUaA2O7pr3Gl/dGFdcYEY1HbqIxMI4j79bPuqO0ITa3LhfDPmHkOB1Ge2dA KesvumMW9dVT8rxlTBlChYwRaNse2SPk1IyJyHb0ZEoRgKMU2GKf2HhE0RjdDLrr4prP m7jut1FGMA8Tx7YmHOGIg6HJ/zdqUeRdt8bLl/vdSmi6Be9KVijc1Jqz43wBsGT02M3E WnxBFoTED6O3t7uDZCelYu7/LtOF5jGT4Y0ZqYaqoxdEQ48aEYjJkhlBx4o0I3vjvH50 y9JrB1ICG/+4ZVJkynQ0jldS2akB8QmzUtHG+8nfp5Y6z3g+LgY5mkOf6CrhrZ3ED3iu VghQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747237992; x=1747842792; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=vGV5dcV3NTwmmW1H5TozP8u9urhrkwXe6SnuhWSBrAg=; b=Wy1Slkw8bugVRIqMgYViVy6k7C4q6k5m7inE0QqlZnW6zy1Vp26/H58yLLq7eI2iTk RzyH6Hf2DnyEZUyKXFR7nib7P5EgA2oeG9HNSourxLBn3AhFFCcrfzdtfqGfTvTKcgiL +0KadZ5mK3p2/dMhnXTNMQfk1/wOVcuZnxGZHYURDdpQY4hBXonmkAeIoL8BbjCCnc1b lRFnT4FEatHCKpy0IizcfQhp0BaYDO4MgLyNOSR/cWNFQguWqbPcj6/t4gyCAxeGTw5/ TgQKKzBtvipAOWln/p7MkcneUmvmldGwaKlzvmLJbjw2wEVRwaf2Xnp2zh58dadv7IZe we5g== X-Forwarded-Encrypted: i=1; AJvYcCWsD12bKShpVXTJ/XE6mZaLdjkHMoUWnrncHaPXTDX74OBVdHiDdxhDQW5SoVc4d5n0mYg2o0kPd+ZmY+u3@lists.postgresql.org X-Gm-Message-State: AOJu0Yz41EQfFUxQcbLWnutCrTavr3+Oxxemz9xaWWsSOvK3ViAf9PGw +SAA8YWSFfEtoW9LPMk4f/Y13FijBD+gvM1X0WM8kcIobcUAC1Cz X-Gm-Gg: ASbGncu2d1qAqa8IpEQijOqZq+XtiZCtzAgGDh8KMI1t7IoQGPmzPsWy5iZUbrVpZ6S c+sNgI/gRxrJ6Y0kzSk/g4eRxdys79ZZe9LKvYy46RCDFe+zeAJDTcaiU3CXJiJvKj/Ged4HghQ mfnyCrD8TmxbH6UyPUYPuFLwSMXI0c97C64JGaYXqQVf11OMM6uNJuCxuj+K9Og2Kls8vjbpGV6 Ng52MQufDNNN+XRRMSUiYxOAXAHiz3czXz6uVENwOpOee/9mKlk+GT6iRXeis27dBTeTOp7+32u mbxZbRPMKd8madY+XlTnXZwKcNII4JKNcZ0Uoiup5v69EC3fztBSPkQs1L4hOT9ZTZZL1K2Kd8b psCG4HUZGzALEQo04yYyTLMldjRMnWdUxqg== X-Google-Smtp-Source: AGHT+IFOeZkRh4uvEXS6385b6Awj3LUXtDJjZteLTpRnFXnFsClBE92UybeXHNbWM/O6WRNG4eioMw== X-Received: by 2002:a05:622a:6108:b0:48a:c5d8:aabf with SMTP id d75a77b69052e-49495cba1e6mr57772861cf.30.1747237991939; Wed, 14 May 2025 08:53:11 -0700 (PDT) Received: from nathan (modemcable171.6-163-184.mc.videotron.ca. [184.163.6.171]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-4945249111dsm80611071cf.27.2025.05.14.08.53.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 May 2025 08:53:11 -0700 (PDT) Date: Wed, 14 May 2025 11:53:08 -0400 From: Nathan Bossart To: Hari Krishna Sunder Cc: Corey Huinker , Jeff Davis , Robert Treat , Robert Haas , Andres Freund , Tom Lane , Michael Paquier , jian he , Bruce Momjian , Matthias van de Meent , Magnus Hagander , Stephen Frost , Ashutosh Bapat , Peter Smith , PostgreSQL Hackers , alvherre@alvh.no-ip.org Subject: Re: Statistics Import and Export Message-ID: References: <8a6905c658ed52418c6f413393390dc43d63a995.camel@j-davis.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, May 13, 2025 at 05:01:02PM -0700, Hari Krishna Sunder wrote: > We found a minor issue when testing statistics import with upgrading from > versions older than v14. (We have VACUUM and ANALYZE disabled) > 3d351d916b20534f973eda760cde17d96545d4c4 > > changed > the default value for reltuples from 0 to -1. So when such tables are > imported they get the pg13 default of 0 which in pg18 is treated > as "vacuumed and seen to be empty" instead of "never yet vacuumed". The > planner then proceeds to pick seq scans even if there are indexes for these > tables. > This is a very narrow edge case and the next VACUUM or ANALYZE will fix it > but the perf of these tables immediately after the upgrade is considerably > affected. There was a similar report for vacuumdb's new --missing-stats-only option. We fixed that in commit 9879105 by removing the check for reltuples != 0, which means that --missing-stats-only will process empty tables. > Can we instead use -1 if the version is older than 14, and reltuples is 0? > This will have the unintended consequence of treating a truly empty table > as "never yet vacuumed", but that should be fine as empty tables are going > to be fast regardless of the plan picked. I'm inclined to agree that we should do this. Even if it's much more likely that 0 means empty versus not-yet-processed, the one-time cost of processing some empty tables doesn't sound too bad. In any case, since this only applies to upgrades from PS: This is my first patch, so apologies for any issues with the patch. It needs a comment, but otherwise it looks generally reasonable to me after a quick glance. -- nathan