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 1otVlp-0003Zu-EB for pgsql-hackers@arkaria.postgresql.org; Fri, 11 Nov 2022 15:16: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 1otVlo-0007zg-A8 for pgsql-hackers@arkaria.postgresql.org; Fri, 11 Nov 2022 15:16: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 1otVlo-0007zW-0d for pgsql-hackers@lists.postgresql.org; Fri, 11 Nov 2022 15:16:40 +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 1otVll-0006bz-Nq for pgsql-hackers@lists.postgresql.org; Fri, 11 Nov 2022 15:16: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 2ABFGZDg522125; Fri, 11 Nov 2022 10:16:35 -0500 From: Tom Lane To: David Geier cc: PostgreSQL Developers Subject: Re: Optimize join selectivity estimation by not reading MCV stats for unique join attributes In-reply-to: References: Comments: In-reply-to David Geier message dated "Fri, 11 Nov 2022 13:01:15 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <522123.1668179795.1@sss.pgh.pa.us> Date: Fri, 11 Nov 2022 10:16:35 -0500 Message-ID: <522124.1668179795@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk David Geier writes: > eqjoinsel() can be optimized by not reading MCV stats if at least one of > the two join attributes is unique. There won't *be* any MCV stats for a column that ANALYZE perceives to be unique, so I'm not quite sure where the claimed savings comes from. > With this change we saw some queries improve planning time by more than > 2x, especially with larger values for default_statistics_target. Please provide a concrete example. regards, tom lane