Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dciyX-0003tS-VT for pgsql-hackers@arkaria.postgresql.org; Wed, 02 Aug 2017 02:01:30 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dciyX-0004EE-Gm for pgsql-hackers@arkaria.postgresql.org; Wed, 02 Aug 2017 02:01:29 +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 1dciyX-0004E5-4K for pgsql-hackers@postgresql.org; Wed, 02 Aug 2017 02:01:29 +0000 Received: from mail-pg0-x229.google.com ([2607:f8b0:400e:c05::229]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1dciyP-0004jO-6V for pgsql-hackers@postgresql.org; Wed, 02 Aug 2017 02:01:28 +0000 Received: by mail-pg0-x229.google.com with SMTP id u185so15020689pgb.1 for ; Tue, 01 Aug 2017 19:01:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=UumJNwKNxic2bqruZkH9N1gRbLZQxD3UHYqLqPAzSw8=; b=SxTHWUnDYb7SFIz/cMNB6KaS6+jqnK0cTR+6QKV3WGQljdMRDTTNjJgRMs6P6O+wVu iTphbyPenAOFJoqlTkQnVle7Atj6x/p2YAIZ+e2AJQHADU9TDlkKzlMdLG4zB+jDZIQ9 xBc1cfR6BlVCj+yBiI2Ln9GtlS+28bHmff9QQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=UumJNwKNxic2bqruZkH9N1gRbLZQxD3UHYqLqPAzSw8=; b=FzFU6YzSXdsApVBXyQhpfRo1kSAbFSenKNqnp38FI+Vr3iHM4WMeXmBvucW1BnDxTI yQA7Qt5OZu3KjAoINbboi3STsRTdRZG5PwGFBhTSrDzpTMgAmJX6ynTOJf7Cc1pMyt4p KeZ4J5ilSI6wIR0/5HF79coe7F/XwUjR+YxdnhCvPjMb+3C6mxX1UuFsp09IDKWh3dB+ gkQzJtlbaVm1NG7pFaW6jDGNaow87yh5/wxFfYPGTQQK9ShOviugKmInd87rDdJLJ0IR 4y9srOXlo0oakDVghbg02vSzoiI2HWpXClZyfdrkyX6CY55ZIhD3m7I323T6zXcIMTE9 E1bQ== X-Gm-Message-State: AIVw113Dj9h7SBeyagiqHNehf/Piz3p0eymQaU8tCdeqPrfTZX2d/Gj1 NefHQmdCa54vFLTG X-Received: by 10.98.211.73 with SMTP id q70mr20839216pfg.285.1501639279003; Tue, 01 Aug 2017 19:01:19 -0700 (PDT) Received: from rfd.leadboat.com (c-73-158-248-138.hsd1.ca.comcast.net. [73.158.248.138]) by smtp.gmail.com with ESMTPSA id s11sm57554817pgr.53.2017.08.01.19.01.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Aug 2017 19:01:17 -0700 (PDT) Date: Wed, 2 Aug 2017 02:01:15 +0000 From: Noah Misch To: Tomas Vondra Cc: Tom Lane , pgsql-hackers@postgresql.org Subject: Re: VACUUM and ANALYZE disagreeing on what reltuples means Message-ID: <20170802020115.GE2611764@rfd.leadboat.com> References: <16db4468-edfa-830a-f921-39a50498e77e@2ndquadrant.com> <19990.1500936945@sss.pgh.pa.us> <3d250597-384e-c5f4-7533-b513e366888f@2ndquadrant.com> <7087.1500995043@sss.pgh.pa.us> <9b594258-57b1-f2cf-f25c-d2caa0a1bc8d@2ndquadrant.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9b594258-57b1-f2cf-f25c-d2caa0a1bc8d@2ndquadrant.com> User-Agent: Mutt/1.5.24 (2015-08-30) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On Tue, Jul 25, 2017 at 07:02:28PM +0200, Tomas Vondra wrote: > On 7/25/17 5:04 PM, Tom Lane wrote: > >Tomas Vondra writes: > >>Attached is a patch that (I think) does just that. The disagreement > >>was caused by VACUUM treating recently dead tuples as live, while > >>ANALYZE treats both of those as dead. > > > >>At first I was worried that this will negatively affect plans in > >>the long-running transaction, as it will get underestimates (due > >>to reltuples not including rows it can see). But that's a problem > >>we already have anyway, you just need to run ANALYZE in the other > >>session. > > > >This definitely will have some impact on plans, at least in cases > >where there's a significant number of unvacuumable dead tuples. So I > >think it's a bit late for v10, and I wouldn't want to back-patch at > >all. Please add to the next commitfest. > > > > I dare to disagree here, for two reasons. > > Firstly, the impact *is* already there, it only takes running ANALYZE. Or > VACUUM ANALYZE. In both those cases we already end up with > reltuples=n_live_tup. > > Secondly, I personally strongly prefer stable predictable behavior over > intermittent oscillations between two values. That's a major PITA on > production, both to investigate and fix. > FWIW I personally see this as a fairly annoying bug, and would vote to > backpatch it, although I understand people might object. I tend to agree. If you have a setup that somehow never uses ANALYZE or never uses VACUUM on a particular table, you might prefer today's (accidental) behavior. However, the discrepancy arises only on a table that gets dead tuples, and a table that gets dead tuples will see both VACUUM and ANALYZE soon enough. It does seem like quite a stretch to imagine someone wanting plans to depend on which of VACUUM or ANALYZE ran most recently. -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers