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 1wpljC-001pwi-2Y for pgsql-bugs@arkaria.postgresql.org; Fri, 31 Jul 2026 11:48:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wpljB-00FsxS-1T for pgsql-bugs@arkaria.postgresql.org; Fri, 31 Jul 2026 11:48:37 +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 1wpljB-00FsxK-0f for pgsql-bugs@lists.postgresql.org; Fri, 31 Jul 2026 11:48:37 +0000 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wplj8-00000001G86-3tUA for pgsql-bugs@lists.postgresql.org; Fri, 31 Jul 2026 11:48:36 +0000 Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-c9c26a5fb98so478886a12.0 for ; Fri, 31 Jul 2026 04:48:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785498512; x=1786103312; darn=lists.postgresql.org; h=in-reply-to:references:to:from:subject:message-id:date:content-type :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to:content-type; bh=N332q8nA6KFgcfna6HsSGWwu1sfgxwXxe2xEyiKGUCY=; b=eERVjECLOSnTuu8og2IQn/rPL1PiEA+8DP2hsgLq0q1F77lO+fLo/MZpn9mIEnbq/E baEGunsC2TVGWhiU2VAY0aH8vGGrRtxo+pYJa97GuXrQQk12A0y5QQINqWQ+rAV0gT+Q WwO3ZKSq+AtZYl9TRjGEHuK5sbFz9m1A5P95Eqe5tLQRgKITiF6HORw63GTZXsAvfpto vyhzqhB2NGyRIM17qBustxnDDJ27PTkaeu+cCH6DCfRhLgjUv57YHUZERpR3YwCJwVQ+ PNS62WUphhlxNBvr6FT/I9UH4kvkevqTJd8D6joth8jb+cizcfZ5H/ZEfmHBCkYzaFaH ujAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785498512; x=1786103312; h=in-reply-to:references:to:from:subject:message-id:date:content-type :content-transfer-encoding:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to:content-type; bh=N332q8nA6KFgcfna6HsSGWwu1sfgxwXxe2xEyiKGUCY=; b=rOe4kTqFKUilv0/MwQQZc1VZynuLoz+OIFKeElbmmGDF/59tOyL4tCIADULLOIPLDu QxTGuQfS8HIiQtis2QOSKfzpSOuXgyTggcnb1VWv05ZISalXHo0WM6nTdLwHhbxmV6FO sI1adM2pKaCXyelBvVmIdxmRqoQauTo0SLkMOmX/WTxz3NW5e/wwIdY1ypWjCiWHgzke BGy5eNLBAhQhqtG656SwYY3JleyvTrm2uOxTOyIGaznjGXbfRQSwPSkC26nGzlUpE657 R0ttjvBnRfxGBIZcBB8jWefxtUsXS4E2DwbLLm1HdZF+BDHiAtH+N1K3OkTsFJvJvzxK Fn5Q== X-Forwarded-Encrypted: i=1; AHgh+Rpr9zMdWxtIhBcIRvm921xugPtB9tmJxi58h0AwFS/rSW0VfrYRlF4CVrZDtP/CGvB2RUSxbFdVfNfy@lists.postgresql.org X-Gm-Message-State: AOJu0YwweOtjuWHoc8AAdXbY6QH+2jUTKC2RtSg1wX1atpdrb1Beroj7 Ms2PmmzU7mr84ZJLte0cFiPhJP5Df1FHp767oZrF+gklsoiw0tWxt2Wc X-Gm-Gg: AR+sD12+bTU2WRjGIWSPe9zzByBo56ZBiasAL4+8rTB2yymlzMZNMB+mwmaN1cswBR3 kyC7d7KQt+LxeN4ZaViTDG+DvFnSmx1scP5p+25WvqVJ/TaTGws+CRnxZW1kSMfyM/LNwOCgtbw BAmP3bfQ4qHaDlV+DIebOfD10AG3BFLq3e5935XFfxul2MJRydnTmJyoRAZf7cNtgMRn6rwzNhF XvBF27tRpVls46JJsHEznr4ieyBCyXrO/A/USSYdnfVRsdrgTCJXmv5Nfmf6quXPQZrcLX1Jtln kp+QPBx6IKyODK/eaFFIGrZoE8e1QgB6pAWyyw8FohZG/qYNbGaoQOB4xukx5EkFrKtVX/3HIYw +BxYLMnobvB6QsSZvPep6rtlgfHH/I3/tuqd9CXxc5Kmq1I3o7eR3ylcaa0jTonZShi0uGhcDlK 3thXR+NnRyRoYIxOC8r/9fiu8HbwJAuPAOXybZieBQewh5xSZPPFWuR8JasUo8Q9qsFxIbPlNXf 9NsaHthpCk= X-Received: by 2002:a05:6a20:2d28:b0:3c3:75c5:48d5 with SMTP id adf61e73a8af0-3c91a711d0bmr2082296637.4.1785498512148; Fri, 31 Jul 2026 04:48:32 -0700 (PDT) Received: from localhost ([2804:14d:32a7:4273:bc3c:f6dc:aad5:c5b8]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3153e04456dsm4730228eec.14.2026.07.31.04.48.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 31 Jul 2026 04:48:31 -0700 (PDT) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Fri, 31 Jul 2026 08:48:29 -0300 Message-Id: Subject: Re: BUG #19572: Redundant predicate changes JIT decision and causes an 18x performance difference From: "Matheus Alcantara" To: =?utf-8?q?=E9=99=88=E5=88=97=E8=A1=8C?= <2320415112@qq.com>, "pgsql-bugs" X-Mailer: aerc 0.21.0 References: <19572-f770e89412629023@postgresql.org> In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu Jul 30, 2026 at 3:44 AM -03, =3D?utf-8?B?6ZmI5YiX6KGM?=3D wrote: > Thanks for the detailed analysis. > > > You are completely right=E2=80=94the query produces correct results, so i= t's > an estimation/costing issue rather than a correctness bug. > > > Regarding whether it's worth addressing: In real-world applications, > especially those using ORMs or complex auto-generated SQL, redundant > predicates (or transitive quals across joins) are actually quite > common. When a redundant qual causes the estimated row count to drop > significantly, it can severely distort the plan choice or prematurely > cross cost thresholds (like JIT enablement, as seen here). > Yeah, I'm not surprised that ORMs may generate such queries. I've posted about this on -hackers [1]. [1] https://www.postgresql.org/message-id/DKBX1KUW8KUW.2DU5RD192DHIQ%40gmai= l.com -- Matheus Alcantara EDB: https://www.enterprisedb.com