Re: Hash-based MCV matching for large IN-lists

Zsolt Parragi <zsolt.parragi@percona.com>

From: Zsolt Parragi <zsolt.parragi@percona.com>
To: Ilia Evdokimov <ilya.evdokimov@tantorlabs.com>
Cc: David Geier <geidav.pg@gmail.com>, Chengpeng Yan <chengpeng_yan@outlook.com>, Tatsuya Kawata <kawatatatsuya0913@gmail.com>, "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>
Date: 2026-03-11T08:01:37Z
Lists: pgsql-hackers
+ if (elem_nulls[i])
+ {
+ nonmcv_cnt--;
+ continue;
+ }

> The patch v8 can still be reviewed as-is, and if the selectivity
> regression test gets committed [0], I will add corresponding tests for
> this change as well.

Without [0], the const path will return incorrect results for <> ALL
and NULLs. Compared to that, the other path still has special handling
in it:

+ /*
+ * For ALL semantics, if the array contains NULL, assume
+ * operator is strict. The ScalarArrayOpExpr cannot
+ * evaluate to TRUE, so return zero.
+ */



+ nonconst_sel = var_eq_non_const(&vardata, operator,
+ clause->inputcollid,
+ other_op, var_on_left,
+ isInequality);

+ if (isInequality)
+ individual_s = 1.0 - individual_s - nullfrac;

Isn't this the double negation issue again, which was once
mentioned/fixed earlier?

+ int count; /* number of occurrences of current value in */

That's a truncated comment



Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Short-circuit row estimation in NOT IN containing NULL consts