David Rowley <dgrow...@gmail.com> writes: > On Thu, 30 Sept 2021 at 10:20, Tom Lane <t...@sss.pgh.pa.us> wrote: >> I'm still confused. AFAICS, the top-level operator of the qual clause has >> exactly nada to do with the cache keys, as this example makes plain.
> You're right that it does not. The lateral join condition could be > anything. Actually, the more I look at this the more unhappy I get, because it's becoming clear that you have made unfounded semantic assumptions. The hash functions generally only promise that they will distinguish values that are distinguishable by the associated equality operator. We have plenty of data types in which that does not map to bitwise equality ... you need not look further than float8 for an example. And in turn, that means that there are lots of functions/operators that *can* distinguish hash-equal values. The fact that you're willing to treat this example as cacheable means that memoize will fail on such clauses. So I'm now thinking you weren't that far wrong to be looking at hashability of the top-level qual operator. What is missing is that you have to restrict candidate cache keys to be the *direct* arguments of such an operator. Looking any further down in the expression introduces untenable assumptions. regards, tom lane