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 1lj7cB-0005kd-Hs for pgsql-bugs@arkaria.postgresql.org; Tue, 18 May 2021 21:50:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lj7c8-0002lg-Bl for pgsql-bugs@arkaria.postgresql.org; Tue, 18 May 2021 21:50:56 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lj7c8-0002lW-4b for pgsql-bugs@lists.postgresql.org; Tue, 18 May 2021 21:50:56 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lj7c5-0002fo-6D for pgsql-bugs@postgresql.org; Tue, 18 May 2021 21:50:55 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id B55C15C0183; Tue, 18 May 2021 17:50:51 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 18 May 2021 17:50:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=kJCKTI5KYuXyN/KaDJAsk+t3fpdSL+wBEOwmUIy8/q8=; b=dQ1qXiON F1DbXIbSp10lGl8uKdD9J7ZjFoMQ5C+4N8goQ0l2DxnASBuApnyIqo83bhMHdHPD YW/1/x2Lzw0eRUe3QKG3oxCNZEe2NIlEjtXc6a+hr6k5zx7eLm1DX9lIyDJJGhv8 WnunP2NkHFZSpf49KZt//3bG5O+U/mayBPpGCHYmr3NXW9X/HSEaNqAMc6F4MObC LwE1He93cvie3KA8aXZea72TdMKgOtTjfqhG5StXorY3DlQbJuHAAB7r6i0dGDj0 gdpHqIlTBGe24tm9aRk1QoBXTFLUNMEuug0ioiN+WEB2xfT6dZThuu/IsViRUKES Vo/iezoz7+cV2w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdeikecutefuodetggdotefrodftvfcurf hrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecuogfuuhhsphgvtghtffhomhgrihhnucdlgeelmdenucfjug hrpeffhffvuffkgggtugfgjggfsehtkeertddtredunecuhfhrohhmpeetlhhvrghrohcu jfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgqeenuc ggtffrrghtthgvrhhnpeekfedugeetvdetgeefgffhkeeufeekvedtkeffhfeiieeihfef ffeuffejueduleenucffohhmrghinhepphhsuhdrvgguuhdpghhoohhglhgvrdgtohhmne cukfhppeduledtrdelhedrudelrdelheenucevlhhushhtvghrufhiiigvpedtnecurfgr rhgrmhepmhgrihhlfhhrohhmpegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorh hg X-ME-Proxy: Received: from perhan.alvh.no-ip.org (unknown [190.95.19.95]) by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 18 May 2021 17:50:51 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 1D3092A0ADA; Tue, 18 May 2021 17:50:48 -0400 (-04) Date: Tue, 18 May 2021 17:50:48 -0400 From: Alvaro Herrera To: Tom Lane Cc: James Coleman , pgsql-bugs@postgresql.org Subject: Re: Less selective index chosen unexpectedly Message-ID: <20210518215048.GA22962@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <3375038.1621373660@sss.pgh.pa.us> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2021-May-18, Tom Lane wrote: > The only thing I see that's really going wrong here is marginally > inaccurate stats, especially right after a big insertion that's > not reflected into the stats yet. I'm not sure there's much to > improve there. You could increase the stats target some more, > though of course that just pushes out the size of table where > the issue will appear. I think the real winner would be a mechanism to incrementally analyze tables, so that it updates the existing stats by sampling only blocks that have new data, and "somehow" merge that into the existing statistics. You could have such a process run much more frequently than standard analyze, because the cost is [supposed to be] smaller. Of course, the big problem with this idea is how would you merge/update the stats at all in the first place. ... ah, it appears there have been attempts at this already: https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.63.5414&rep=rep1&type=pdf -- Álvaro Herrera Valdivia, Chile "Ed is the standard text editor." http://groups.google.com/group/alt.religion.emacs/msg/8d94ddab6a9b0ad3