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 1wOrei-000FLC-0Q for pgsql-bugs@arkaria.postgresql.org; Mon, 18 May 2026 06:40:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wOree-001NzE-1r for pgsql-bugs@arkaria.postgresql.org; Mon, 18 May 2026 06:40:45 +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 1wOree-001Nz5-0u for pgsql-bugs@lists.postgresql.org; Mon, 18 May 2026 06:40:45 +0000 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wOrec-000000008Cy-2Ncp for pgsql-bugs@lists.postgresql.org; Mon, 18 May 2026 06:40:44 +0000 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-43d73422431so1145342f8f.2 for ; Sun, 17 May 2026 23:40:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779086441; x=1779691241; 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=bP0iat77H/cDN+jdSwcB7r6m5uHYSxJx9VjbOR2xBwo=; b=iYwh9Ji91HY/3TJTYJsRnF9XKz8q/s8RAVhx51vy+Fnie6jWkETAziSgG7zKrVyJj+ FBVWL3XCh9hatauRtNOW3hzpYM3lz8tFleQkOHJ/Um2gruRBNGJMaRCdxdHs0wb0yAce sTK1mm0sOED84JbnWAc/uXHL5iCWhiJmStYDljbucnBd8GVvwmSiHKJQ3aULhf88Pfde wzyTQcRgBrdkI79AzgSbuQJ3UEtZrNi3foPvx9xCzODz00l5jUOk+jeUlS0wCVNOAZwY VAItDZ8J6y03esDNml61w/aCY4sOfOIUjNeu+pLeUokT+vhIpzOdcIeWqL2jYmlqlnSM pdxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779086441; x=1779691241; 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=bP0iat77H/cDN+jdSwcB7r6m5uHYSxJx9VjbOR2xBwo=; b=FMQCt67x5vff6QbCClelFfuPNMAVVrlzyahT8OkljwS3wWA9Ur7G4CXWsZ/Zzr1GFz 8GmW8IH/VhF6SUpOkAu6bPbjGGnvj3jV2mfC7d78XE+jd5X1Ec2VAUWzaFne+vZtWKQh 89YdZLWo8PmqZjDaVtCIgJ7nArzdeT5HTYKu6M8pe72qo6vFdTcb4a6r28wflztf80xQ GoLtlwM68J/PHWEd2pqT4jGQ3tGdPFaFNIttjNF+00H8IeduwSplj6Z12zzEmvukiYzI 93JSk15440Bod/n0CbDcYz7k70JHRg+sZgZIp0wuqjaolw75i5hVW6K9PQyeIfJG0AcZ cm5w== X-Forwarded-Encrypted: i=1; AFNElJ9177zCLvnBZTIVnRpZV04zKsRGLaoKUMGI51OiNSXgadAkAmP7ETGCMAvZx/m/6g99ISniHlJ51Lkf@lists.postgresql.org X-Gm-Message-State: AOJu0Ywmc+xr2+GWsND+MBOQFBbY+/DLG22RFwDMqweezkWOEmTYHtix hHX/bA6ehYygmXI3IVqsE3x29Mw9iJtEkAzKmCJf4Lqlugg2fyA3IPYc X-Gm-Gg: Acq92OGXJ8zsV42bQbJipEzPsFe5hiuPg1p1iE6pzzl2YEtMtckkF9sN51rSuJE8/zq 8NOvFelwPsbbktMvyc5B/ULnBuFmKfoHEa5VM3QCoqutKya+SOUB0i/7k35EF3VnXY2oqC0iQTv bHQ5cHt3nKeDT/hr9xOL0HC7z69ty74qbYaFo654sKgWEMKKnCqPu9QiQypg0DBUV5LCp5hmwIw 1UI5VJKZpoirFLKvr2wLHtxVjPI+ynNbBS7/ytMRvuHtBLfWPAZke+/pIOAFIuQVnSVDxcvTVvt sF5a2n9JIb6dJVq2JnCQk4xhRO/d9h7nLTtlkhlmXXhKlRLBwzM65c7O0HihOnJa2myWJ5CwPPe ptKuqZhmUlgXLJ72qBBGngqtIMptQiweJtmKUb282xIfdDur58uvONJnYO4DdTyrEFr+uwsNQNm 9m+taXcBqCuGrNZ2qI7rfABvxbV0fHwYZD+LpZ9fwejxmiqbs= X-Received: by 2002:a05:6000:22c5:b0:43d:6fb7:fedb with SMTP id ffacd0b85a97d-45e5c60a30cmr22254939f8f.36.1779086440926; Sun, 17 May 2026 23:40:40 -0700 (PDT) Received: from [192.168.15.82] ([80.251.191.198]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45e7c22d8b7sm5642211f8f.6.2026.05.17.23.40.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 17 May 2026 23:40:40 -0700 (PDT) Message-ID: <77c94271-4552-4797-9fc4-ec2c3817e53f@gmail.com> Date: Mon, 18 May 2026 08:40:39 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: BUG #19481: multivariate MCV expression stats not applied for equivalent predicates on nullable side of LEFT JOI To: yankairong@ruc.edu.cn, pgsql-bugs@lists.postgresql.org, PG Bug reporting form References: <19481-4afc34accc9043fe@postgresql.org> Content-Language: en-US From: Andrei Lepikhov In-Reply-To: <19481-4afc34accc9043fe@postgresql.org> 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 16/05/2026 12:07, PG Bug reporting form wrote: > That strongly suggests the extended expression MCV stats are still not being > matched for equivalent predicates on the nullable side of the outer join. The query explain tells the whole story: Nested Loop Left Join Filter: ((COALESCE(mod(m.a, 20), 1) = 1) AND (COALESCE(mod(m.b, 10), 1) = 1) AND (COALESCE(mod(m.c, 5), 1) = 1)) -> Result -> Seq Scan on mcv_bug m As you can see, this clause is a JOIN clause. Your coalesce filter applies to the result of the join. But m.a,m.b, and m.c might be changed (nullified) in this join. So, your extended statistic isn't applicable here. To be relevant, it should calculate the number of not-matched LHS tuples and account for them. In your case, the ON clause is 'true', so all tuples will be matched. It is a degenerate case and might potentially be improved, but it doesn't look like a bug. -- regards, Andrei Lepikhov, pgEdge