Hi, thanks for working on this!

On Wed Feb 18, 2026 at 9:48 AM -03, Ilia Evdokimov wrote:
> I've fixed all the comments raised above and updated the v5 patch.
>

Here are some comments regarding v5 patch:

On scalararraysel() we have:

+                               ReleaseVariableStats(vardata);
+
+                               if (s1 >= 0.0)
+                                       return s1;

I'm wondering if we also should call ReleaseVariableStats() on the early
return?

+                                       if (!useOr && elem_nulls[i])
+                                       {
+                                               pfree(elem_values);
+                                               pfree(elem_nulls);
+                                               pfree(elem_const);
+
+                                               return (Selectivity) 0.0;
+                                       }

------------------

On scalararray_mcv_hash_match() free_attstatsslot() is called only on
if (have_mcvs && OidIsValid(hashLeft) && OidIsValid(hashRight)),
perhaps it should be moved outside the if condition?

+       if (have_mcvs && OidIsValid(hashLeft) && OidIsValid(hashRight))
+       {
+       ...

+               MCVHashTable_destroy(hashTable);
+               free_attstatsslot(&sslot);
+       }
+
+       return selec;


------------------

typo: "all elements are const"

+ *              array is NULL if all elemnets is const.

------------------

It's worth adding on scalararray_mcv_hash_match() an early return when
num_elems == 0? I imagine that this can happens, e.g "WHERE a =
ANY(array[]::int[]);". In this case the function should still execute
completely?

--
Matheus Alcantara
EDB: https://www.enterprisedb.com


Reply via email to