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 1x2Vak-005oFt-0N for pgsql-bugs@arkaria.postgresql.org; Fri, 04 Sep 2026 15:12:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1x2Vai-007YTq-2m for pgsql-bugs@arkaria.postgresql.org; Fri, 04 Sep 2026 15:12:32 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1x2Vai-007YTh-1g for pgsql-bugs@lists.postgresql.org; Fri, 04 Sep 2026 15:12:32 +0000 Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1x2Vag-00000002vu0-0Tjn for pgsql-bugs@lists.postgresql.org; Fri, 04 Sep 2026 15:12:32 +0000 Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-5b01910b499so1088689e87.0 for ; Fri, 04 Sep 2026 08:12:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788534744; x=1789139544; darn=lists.postgresql.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=HD5sV3ulxx404yyoJHo51ZWTwFluM72MWMFNmEdifXk=; b=NT2ERaHwR2bppnUG25oRPKHW/oOIt2KeafqA5SOoD+l7bnQzaW8BmZhXChnPTduTqR 3g2ufLKaR/+FXmuZtJrH3537pvOpQhePWZMnusB809jNoSmE24dlEd5X1Jh+zZxd0BFK HYUc9YC0ti1hUyp+SYX+vnXFcAl05bPoY4HeaJ9KslKm3YgLfyLwkU1G/uV6TeWGbGii 5155AZOhnQJyfVlWIDp6ILpQqvsS+9jurdKzyWfXEyEisDpvMvon2hQp3zx4R9FQUUpN X4zjqMvzfQcCYAMC37CFbeh8pghHssywm49hOI9XcPNTW66rehPwXPPm9tZ/ii5mfUBL 18HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788534744; x=1789139544; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc: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:content-type; bh=HD5sV3ulxx404yyoJHo51ZWTwFluM72MWMFNmEdifXk=; b=RUH7uMgL5kflonm1qT9r7w3IVm/ccER4OFDuzNrVI1AffsbSH32+oo2uUvN8xGPhnf 8Zx2P/RZMauIJOWc+tn5mvwvp9juO1K4jYf0a+csbypDlVHe8Ub5BkSoMaLjokohHoP0 vw0L5tEISR+Z+u3i4rJYFpzIJMif87P0hXTpWLX0P+n6FxE1mbdtDNdP7lBEh5hS1bbE VfFFPfEe3qAXGBEw1IAlVFneSxkg6nHKcOLbXieOLx8cLtbPW6xuTeEYhXQ74fhvmqws sS5sa2+ftmhqyquk6OQpm7jXnIiXm2BNnxUa0l0JbEaV4fNDCrFeCki+93IbL9IevGr+ SMVg== X-Forwarded-Encrypted: i=1; AKwUvBy2Z//SHB9plOOZfhQeUaQvHu6URdiU8sGBHWpsUs3F/rSp2TqAAsrsT3VxI0Jc/jWmagbBdMxfB6o/@lists.postgresql.org X-Gm-Message-State: AFuF++lJXBKd+v3A9ui7AEf/syyuGth6YZsCPIj3ebWDlvbrm8GRAcf7 Tc/zjah/XO5ki2uprVb7zFCghKHaTXXMxVJ1EzuzcKrCaD7199sLK072 X-Gm-Gg: AYBFou2lytiGHZLpWs/QqZgiowbK/JOqAk1vDqedC+JhS5uQQ8BdDsCQkWnLqlS1Wn4 No5jdXDAYvsXZmbkbpKMgUDbAIR/lEL0k/LxVZ7hhH/1L/t8ywSIy0IAwYnujKHkc8FQq3Arl7w MPV5gX7poXCxWMGMc3x4HpLKNj1EJ4Vg8b9sEgQsN91d/qWcb/ylf77cfdhxQWDEwFOLJfEyNAM f9M87EyY7iVwEBh2mfmT4GSab1wC5tV+vZVQOSs29nq0Er/2vpnV62IhvAfNRDAXr1BZif46HBM RjjaQO2+KJc7I9qkHqFNgBEhLzy6hgycDmErrJ73Cft/xomDNko7YQ7vBXwgHKlTWCPgncL5GMs sIHjcgygP6I5O8EqdXoEIuRbzpOxshpuj/uOS0uwIfUSRtZaR5ggiceSfshhaIxtu7upvgzmCwx 1bRE3TLzg3UzJZoIhLQmn8ZFpoRLETrXFrsWnZmsu2LC1xF0E6YM8+/tO4mYcptb/G6IQi07OUW LXLs+UcJRDi X-Received: by 2002:a05:6512:8395:b0:5b6:199d:c1c6 with SMTP id 2adb3069b0e04-5b6199dc305mr576572e87.37.1788534743786; Fri, 04 Sep 2026 08:12:23 -0700 (PDT) Received: from [192.168.15.240] ([80.251.191.198]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5b61670496asm589094e87.63.2026.09.04.08.12.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Sep 2026 08:12:22 -0700 (PDT) Message-ID: <60c6b1f7-f435-4ca7-992a-482417af5130@gmail.com> Date: Fri, 4 Sep 2026 17:12:20 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: BUG #19649: Qual pushdown into GROUP BY subqueries ignores non-equivalence-preserving references to grouping col To: Andrey Rachitskiy , 303677365@qq.com, pgsql-bugs@lists.postgresql.org Cc: Tender Wang References: <19649-2cabf1440793cc71@postgresql.org> Content-Language: en-US From: Andrei Lepikhov In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 03/09/2026 23:17, Andrey Rachitskiy wrote: > This blocks wrapper-based finer equivalence at pushdown boundaries while > preserving existing behavior for truly direct operands. I don't like this fix. It causes regressions where we haven't had it before. Let's see: CREATE TABLE r(i int, s text, ts timestamptz); EXPLAIN (COSTS OFF) SELECT * FROM (SELECT i, count(*) c FROM r GROUP BY i) s WHERE i::text = '5'; Before: GroupAggregate Group Key: r.i -> Sort Sort Key: r.i -> Seq Scan on r Filter: ((i)::text = '5'::text) With your fix: HashAggregate Group Key: r.i Filter: ((r.i)::text = '5'::text) -> Seq Scan on r I think, filter should be pushed down to the scan. -- regards, Andrei Lepikhov, pgEdge