Re: BUG #17213: Wrong result from a query involving Merge Semi Join and Memoize
David Rowley <dgrowleyml@gmail.com>
From: David Rowley <dgrowleyml@gmail.com>
To: elprans@gmail.com, PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Date: 2021-10-05T07:05:06Z
Lists: pgsql-bugs
Attachments
- bug17213_explain.txt (text/plain)
- bug17213.sql (application/octet-stream)
On Tue, 5 Oct 2021 at 13:14, David Rowley <dgrowleyml@gmail.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
Commits
-
Flush Memoize cache when non-key parameters change, take 2
- c2dc7b9e1503 14.2 landed
- 411137a42921 15.0 landed
-
Flush Memoize cache when non-key parameters change
- f94edb06ab60 14.2 landed
- 1050048a3157 15.0 landed