Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1txnT3-00Eolr-QX for pgsql-hackers@arkaria.postgresql.org; Thu, 27 Mar 2025 13:40:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1txnT2-006l91-8N for pgsql-hackers@arkaria.postgresql.org; Thu, 27 Mar 2025 13:40:20 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1txnT1-006l5a-Ui for pgsql-hackers@lists.postgresql.org; Thu, 27 Mar 2025 13:40:19 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1txnSz-001R88-31 for pgsql-hackers@postgresql.org; Thu, 27 Mar 2025 13:40:19 +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 52RDeGDE1901910; Thu, 27 Mar 2025 09:40:16 -0400 From: Tom Lane To: Richard Guo cc: Ilia Evdokimov , pgsql-hackers Subject: Re: Remove vardata parameters from eqjoinsel_inner In-reply-to: References: <7cdf4ecd-8789-4d85-ab59-2b78d4d27b1f@tantorlabs.com> Comments: In-reply-to Richard Guo message dated "Thu, 27 Mar 2025 16:48:03 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <1901908.1743082816.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Thu, 27 Mar 2025 09:40:16 -0400 Message-ID: <1901909.1743082816@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Richard Guo writes: > On Fri, Feb 21, 2025 at 7:04 PM Ilia Evdokimov > wrote: >> When calculating selectivity for an inner equijoin, we call >> eqjoinsel_inner, which uses unused parameters vardata1 and vardata2. >> These parameters might have been left behind accidentally when we moved >> getting sslots out of the function. I suggest removing them, as they can >> be added back at any time if needed. I attached patch with fixes. > Yeah, these parameters haven't been used since a314c3407, when we > moved get_variable_numdistinct and get_attstatsslot out of > eqjoinsel_inner and eqjoinsel_semi to avoid repetitive information > lookup when we call both eqjoinsel_inner and eqjoinsel_semi. > I'm wondering whether we should also remove parameter vardata1 from > eqjoinsel_semi. vardata2 is still needed though to clamp nd2 to be > not more than the rel's row estimate. I do not believe this change is worth the code churn. In the first place, we may well need those values again someday. In the second place, the savings would be negligible. (In fact, since eqjoinsel_inner probably gets inlined at its sole call site, the savings would likely be completely nonexistent.) If the caller could avoid calculating the vardata info at all, that would be worth thinking about, but I think it can't. regards, tom lane