Re: Use merge-based matching for MCVs in eqjoinsel - Mailing list pgsql-hackers

From Ilia Evdokimov
Subject Re: Use merge-based matching for MCVs in eqjoinsel
Date
Msg-id bc35bcb5-238f-4cfc-837a-8b5722ff5c3b@tantorlabs.com
Whole thread Raw
In response to Re: Use merge-based matching for MCVs in eqjoinsel  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On 03.09.2025 23:26, Tom Lane wrote:
> Ilia Evdokimov <ilya.evdokimov@tantorlabs.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




pgsql-hackers by date:

Previous
From: Daniel Gustafsson
Date:
Subject: Re: docs: Table 9.46. UUID Extraction Functions
Next
From: Dean Rasheed
Date:
Subject: Re: Fix replica identity checks for MERGE command on published table.