Re: Use merge-based matching for MCVs in eqjoinsel

From: Ilia Evdokimov <ilya(dot)evdokimov(at)tantorlabs(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Use merge-based matching for MCVs in eqjoinsel
Date: 2025-09-04 11:05:50
Message-ID: bc35bcb5-238f-4cfc-837a-8b5722ff5c3b@tantorlabs.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 03.09.2025 23:26, Tom Lane wrote:
> Ilia Evdokimov <ilya(dot)evdokimov(at)tantorlabs(dot)com> writes:
>> I’ve attached v3 of the patch. This version adds a check for NULL values
>> when comparing MCV entries, ensuring correctness in edge cases.
> Um ... what edge cases would those be? We do not put NULL into
> MCV arrays.

You're right - MCV arrays never contain NULLs. However, comparing two
MCV values could theoretically return NULL, even though this is very
unlikely. This check existed even before my changes, and similar checks
are used in other selectivity-estimation functions in 'selfuncs.c'.

...
fcinfo->isnull = false;
fresult = FunctionCallInvoke(fcinfo);
if (!fcinfo->isnull && DatumGetBool(fresult))
...

By "edge cases" I was referring to this situation; I probably did not
choose the best wording.

--
Best regards,
Ilia Evdokimov,
Tantor Labs LLC,
https://tantorlabs.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Dean Rasheed 2025-09-04 11:07:10 Re: Fix replica identity checks for MERGE command on published table.
Previous Message Daniel Gustafsson 2025-09-04 11:04:05 Re: docs: Table 9.46. UUID Extraction Functions