Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k3nY5-0001F9-3g for pgsql-hackers@arkaria.postgresql.org; Thu, 06 Aug 2020 21:35:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k3nY4-0002kz-20 for pgsql-hackers@arkaria.postgresql.org; Thu, 06 Aug 2020 21:35:40 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k3nY3-0002ks-Qu for pgsql-hackers@lists.postgresql.org; Thu, 06 Aug 2020 21:35:39 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k3nY1-00057J-Ra for pgsql-hackers@lists.postgresql.org; Thu, 06 Aug 2020 21:35:38 +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 076LZX2U2647181; Thu, 6 Aug 2020 17:35:33 -0400 From: Tom Lane To: Robert Haas cc: Andres Freund , Alvaro Herrera , James Coleman , pgsql-hackers , Simon Riggs Subject: Re: PROC_IN_ANALYZE stillborn 13 years ago In-reply-to: References: <20200805021435.GA9523@alvherre.pgsql> <20200805235549.GA8118@alvherre.pgsql> <20200806010711.mzvu36zy25xer33t@alap3.anarazel.de> <2637311.1596739058@sss.pgh.pa.us> <2638833.1596741087@sss.pgh.pa.us> Comments: In-reply-to Robert Haas message dated "Thu, 06 Aug 2020 16:22:23 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2647179.1596749733.1@sss.pgh.pa.us> Date: Thu, 06 Aug 2020 17:35:33 -0400 Message-ID: <2647180.1596749733@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Robert Haas writes: > ... how > important is stability to ANALYZE? If you *either* retake your MVCC > snapshots periodically as you re-scan the table *or* use a non-MVCC > snapshot for the scan, you can get those same kinds of artifacts: you > might see two copies of a just-updated row, or none. Maybe this would > actually *break* something - e.g. could there be code that would get > confused if we sample multiple rows for the same value in a column > that has a UNIQUE index? But I think mostly the consequences would be > that you might get somewhat different results from the statistics. Yeah, that's an excellent point. I can imagine somebody complaining "this query clearly matches a unique index, why is the planner estimating multiple rows out?". But most of the time it wouldn't matter much. (And I think you can get cases like that anyway today.) > It's not clear to me that it would even be correct to categorize those > somewhat-different results as "less accurate." Estimating two rows where the correct answer is one row is clearly "less accurate". But I suspect you'd have to be quite unlucky to get such a result in practice from Simon's proposal, as long as we weren't super-aggressive about changing ANALYZE's snapshot a lot. regards, tom lane