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 1ow3tl-0002Dz-Hx for pgsql-hackers@arkaria.postgresql.org; Fri, 18 Nov 2022 16:07:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ow3tk-0003V9-6j for pgsql-hackers@arkaria.postgresql.org; Fri, 18 Nov 2022 16:07:24 +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 1ow3tj-0003TT-Tf for pgsql-hackers@lists.postgresql.org; Fri, 18 Nov 2022 16:07:23 +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 1ow3th-0003Za-Mu for pgsql-hackers@lists.postgresql.org; Fri, 18 Nov 2022 16:07:22 +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 2AIG7IOu2233222; Fri, 18 Nov 2022 11:07:19 -0500 From: Tom Lane To: David Geier cc: Tomas Vondra , Richard Guo , PostgreSQL Developers Subject: Re: Optimize join selectivity estimation by not reading MCV stats for unique join attributes In-reply-to: <2a4917f7-8a4d-0094-7189-3a6dcaebad44@gmail.com> References: <522124.1668179795@sss.pgh.pa.us> <16acb727-24e8-6453-1711-aae339802966@gmail.com> <2f30ba9c-b707-55ae-0afd-68eb6a8a7708@enterprisedb.com> <2067066.1668731970@sss.pgh.pa.us> <2106238.1668735410@sss.pgh.pa.us> <2130228.1668748896@sss.pgh.pa.us> <712310f5-a5c7-b833-4f71-b562c5f2de9b@gmail.com> <53950f93-8cce-4440-52f1-5879653c6803@enterprisedb.com> <2a4917f7-8a4d-0094-7189-3a6dcaebad44@gmail.com> Comments: In-reply-to David Geier message dated "Fri, 18 Nov 2022 16:59:02 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2233220.1668787638.1@sss.pgh.pa.us> Date: Fri, 18 Nov 2022 11:07:18 -0500 Message-ID: <2233221.1668787638@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk David Geier writes: > On 11/18/22 14:00, Tomas Vondra wrote: >> Seems fine. I wonder if we could/could introduce a new constant for 0, >> similar to ATTSTATSSLOT_NUMBERS/ATTSTATSSLOT_VALUES, instead of using a >> magic constant. Say, ATTSTATSSLOT_NONE or ATTSTATSSLOT_CHECK. > Good idea. I called it ATTSTATSSLOT_EXISTS. New patch attached. No, I don't think it's a good idea. The flags argument is documented as, and used as, a bitmask of multiple options. Passing zero fits fine with that and is consistent with what we do elsewhere. Turning it into sort-of-an-enum-but-not-really isn't an improvement. I didn't like your draft comment too much, because it didn't cover what I think is the most important point: after a call with flags=0 we do not need a matching free_attstatsslot call to avoid leaking anything. (If we did, this patch would be a lot hairier.) I rewrote the comment the way I wanted it and pushed. regards, tom lane