Re: BUG #17213: Wrong result from a query involving Merge Semi Join and Memoize

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: elprans(at)gmail(dot)com, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #17213: Wrong result from a query involving Merge Semi Join and Memoize
Date: 2021-10-05 07:05:06
Message-ID: CAApHDvpYBqF6KACNhCBdWZo02VSoYQ=XgpiwvQVK=wjpaBE03g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Tue, 5 Oct 2021 at 13:14, David Rowley <dgrowleyml(at)gmail(dot)com> wrote:
> It does look a bit like memoize is not properly taking into account
> the fact that there's a subplan below the memoize node with parameters
> from above the memoize node. Namely the i1.id in issue_id != i1.id.

It looks like that's exactly what the problem is here. I've made a
small adjustment to your script to call analyze on the watchers table.
This does not result in the exact plan that you reported, but it does
result in a Memoize plan that shows the same bug.

I'm currently thinking over what the best fix for this should be. My
current thinking is that all parameters that are from above the
Memoize that are required below the Memoize must be part of the Cache
Key. Currently, it seems, that's not the case and in the plan from the
attached plan, i1.id is being used below the Memoize but originates
from above it.

I'll need to look into how exactly to determine around when
get_memoize_path() is called how we determine if there's any subplan
parameters that will be needed in the Memoize path's sub path that
originates above the memoize node.

David

Attachment Content-Type Size
bug17213_explain.txt text/plain 3.9 KB
bug17213.sql application/octet-stream 1.4 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Verona, Luiz 2021-10-05 09:57:36 RE: Extension relocation vs. schema qualification
Previous Message PG Bug reporting form 2021-10-05 05:41:49 BUG #17214: HammerDB-v4.2-TPCH build schema error for virtual users.