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.96) (envelope-from ) id 1wA1i2-001zi4-2W for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Apr 2026 08:22:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wA1i1-00FkRd-0l for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Apr 2026 08:22:53 +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.96) (envelope-from ) id 1wA1i0-00FkRV-36 for pgsql-hackers@lists.postgresql.org; Tue, 07 Apr 2026 08:22:53 +0000 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wA1hz-00000000zzg-2C1V for pgsql-hackers@lists.postgresql.org; Tue, 07 Apr 2026 08:22:52 +0000 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4887eca00c4so31985345e9.2 for ; Tue, 07 Apr 2026 01:22:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775550170; x=1776154970; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=svDqC8Beg+wgcArFXnpCvduEHlqy1tF/ANR0OfH7o0A=; b=jbujtdp5saJaUwiEQtpcjeTHRRY3Ki65FRb984q6287DxnG1VoSViSWVasprXpD2RL KAj5vqKpuWfneokOq42enXN/f9GtkcAdGNmaQ+dmCRhJxzAoqDce0tuz47MTBITzBFJJ e9TdYYvYVxXq0QYSyncEUWEleJ6rBKQkE9sOD9Rq5vrIB7vnp5mxSTX6Zj+H6PvaIV9N SAseOqZ7PmqUXIL4xrSOVb2MCTg+CTPeluyNjUH4tq8PoOtjIbYMsiZHeKiXcC2h593T IqCHsoaSkFVPvdJAZF+vuB2viwg/olMsDf8E2UJ5NL7h1ZIwqF9gqnjgZWxXMkXR5wHa 6NUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775550170; x=1776154970; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=svDqC8Beg+wgcArFXnpCvduEHlqy1tF/ANR0OfH7o0A=; b=mFA1kY02M0wYiZg14HokbUTHm6+sNn7e5l8koWdFEa2ZAwcpAMfJHmWleSHoEBy+jy Uph04NDCnXToxobqvZIMgJZ04gaoZmJFuYLwjqXny0t5XmG3xDjxVXN4whtzQ2zreIIx +kSiAaYNSt72GOVMxxWqCDdenGHFYkrVol99jiJWH++VKH6kprvR7oMAdV4384xdJwD2 ulxpR2X0VnixZEjCe9jyJY6w6fP95QTizozOrBeLGG45dFJ6fOmJiYYcRYyNify/fT4e cNinfN/8Ijtk80Ihjjt1AUFxQDc7KopjxT7EQtpcQeDSJ6Y/UPjRyw8r/vhi5rN7b+qp QZ3g== X-Forwarded-Encrypted: i=1; AJvYcCVoZkx2t0tAwpKefcVNp/Wd/aVLh5eB/9T7wtePn4juZlkDFQcivH0vzfd0ewVhPJrEvXLnX652bmjEpRVf@lists.postgresql.org X-Gm-Message-State: AOJu0YyILMfyXJF5AKlE/GlvaqiheCbfCLs/ikbx6LwC7JVnOnCJqy7L r9bIc0gUn7gPMxHNLlM0Cl4d7Nt8B3Yeylp3tmIf6cUeS5cL0JeCq2+z X-Gm-Gg: AeBDieuDNIDPSK6nbJVD5CCw1u0jxIz6IW+EcUhzyyvYoP3MEbl2GSQHJYtNqTcrSfF 4i0l8LiS5rLr9atl0jbZqiTUQYNLoKvOURb/02a+VqTyTs6qJK0d8IJcqaqPNQD7GxJpEnqOIW+ 320j2mLkxUnOQutoILvlGjxirRlhcaI+ZKscDdmgJTFQWvblneFYY2ThTFmz+7ldu99k0l76HSm pwbU3qQbC3BOQRaswNrRmAz8DgllrqbOMiKwwkB4VTy0HEaJveS9137ChKXcggMWS0Cj7yAEGm0 eiXSP1bmhQpMSta/kn69c1kM1AWXRpjmaCHboVfbe3fENWV/5O4AdAIWQgRbML2AJWEi7YMjaYe hKNf7qTwJkC8fFvNDHONyF/rrBTscm+0Yo/6Gv75/UU4hA2RVRE1tuq3qDKz51XYBYxGvSxO5MX KJr00hN1xL4WKC40cIHkXkecjbv/rIE/CqTMgkFw== X-Received: by 2002:a05:600c:3b18:b0:488:90ac:8f71 with SMTP id 5b1f17b1804b1-488997152camr208706435e9.5.1775550169993; Tue, 07 Apr 2026 01:22:49 -0700 (PDT) Received: from [192.168.15.156] ([80.251.191.198]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-488a91686f9sm263963155e9.10.2026.04.07.01.22.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 07 Apr 2026 01:22:49 -0700 (PDT) Message-ID: <7f6439c7-e5a7-4d0c-82c9-4087794cd9d0@gmail.com> Date: Tue, 7 Apr 2026 10:22:48 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Clean up remove_rel_from_query() after self-join elimination commit To: Richard Guo , Pg Hackers References: Content-Language: en-US From: Andrei Lepikhov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 06/04/2026 10:11, Richard Guo wrote: > Thoughts? Thanks for your efforts! The main goal of the SJE feature was to find common ground within the community - to come up with a solution that everyone could get behind on whether to allow optimisations that address redundant queries and reduce query tree complexity in early planning stages. So, some code roughness was ok. I looked through your code, though maybe not as deeply as this part of the planner deserves. Overall, it looks good, and I didn’t spot any obvious problems, but I do have a few comments. We added some ‘redundant’ checks with future optimisations in mind, so others can rely on these functions to remove tails from query structures or to error if something was left behind. You explicitly write: ‘Each specific caller remains responsible for updating any remaining data structures required by its unique removal logic’ that differs from the initial idea. At the same time, by the end of SJE development, I wasn’t so sure we could invent a universal approach to guarantee the cleanup of the query tree - mostly because of the inherent volatility of the PlannerInfo structure and because we had not agreed to make the parse tree a read-only structure. So, I’m fine with the changes in this patch. -- regards, Andrei Lepikhov, pgEdge