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 1ovpPy-0002fQ-BA for pgsql-hackers@arkaria.postgresql.org; Fri, 18 Nov 2022 00:39:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ovpPx-00042C-5z for pgsql-hackers@arkaria.postgresql.org; Fri, 18 Nov 2022 00:39:41 +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 1ovpPw-0003yL-Su for pgsql-hackers@lists.postgresql.org; Fri, 18 Nov 2022 00:39: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 1ovpPp-0003wJ-OQ for pgsql-hackers@lists.postgresql.org; Fri, 18 Nov 2022 00:39:39 +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 2AI0dUi52067067; Thu, 17 Nov 2022 19:39:30 -0500 From: Tom Lane To: Tomas Vondra cc: David Geier , PostgreSQL Developers Subject: Re: Optimize join selectivity estimation by not reading MCV stats for unique join attributes In-reply-to: <2f30ba9c-b707-55ae-0afd-68eb6a8a7708@enterprisedb.com> References: <522124.1668179795@sss.pgh.pa.us> <16acb727-24e8-6453-1711-aae339802966@gmail.com> <2f30ba9c-b707-55ae-0afd-68eb6a8a7708@enterprisedb.com> Comments: In-reply-to Tomas Vondra message dated "Fri, 18 Nov 2022 01:27:45 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2067065.1668731970.1@sss.pgh.pa.us> Date: Thu, 17 Nov 2022 19:39:30 -0500 Message-ID: <2067066.1668731970@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Tomas Vondra writes: > Or perhaps what if we have a function that quickly determines if the > attribute has MCV, without loading it? I'd bet the expensive part of > get_attstatslot() is the deconstruct_array(). > We could have a function that only does the first small loop over slots, > and returns true/false if we have a slot of the requested stakind. Yeah, I like this idea. > It might even check the isunique flag first, to make it more convenient. That would tie it to this one use-case, which doesn't seem advisable. I think we should forget the known-unique angle and just do quick checks to see if both sides have MCVs. regards, tom lane