Re: BUG #19481: multivariate MCV expression stats not applied for equivalent predicates on nullable side of LEFT JOI
Andrei Lepikhov <lepihov@gmail.com>
From: Andrei Lepikhov <lepihov@gmail.com>
To: yankairong@ruc.edu.cn, pgsql-bugs@lists.postgresql.org,
PG Bug reporting form <noreply@postgresql.org>
Date: 2026-05-18T06:40:39Z
Lists: pgsql-bugs
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
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Ignore nullingrels when looking up statistics
- e28033fe1af8 18.0 cited