From: | Richard Guo <guofenglinux(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, David Rowley <dgrowleyml(at)gmail(dot)com> |
Subject: | Re: Wrong query results caused by loss of join quals |
Date: | 2023-02-23 09:37:44 |
Message-ID: | CAMbWs49dONbxqs8Yz8JOD45+76pUk0QhCG1pGvD5+RM2aRrBfg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Thu, Feb 23, 2023 at 4:50 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> I thought about this and decided that it's not really a problem.
> have_relevant_joinclause is just a heuristic, and I don't think we
> need to prioritize forming a join if the only relevant clauses look
> like this. We won't be able to use such clauses for merge or hash,
> so we're going to end up with an unconstrained nestloop, which isn't
> something to be eager to form. The join ordering rules will take
> care of forcing us to make the join when necessary.
Agreed. And as I tried, in lots of cases joins with such clauses would
be accepted by have_join_order_restriction(), which always appears with
have_relevant_joinclause().
> The only easy improvement I can see to make here is to apply the old
> rules at inner joins. Maybe it's worth complicating the data structures
> to be smarter at outer joins, but I rather doubt it: we could easily
> expend more overhead than we'll save here by examining irrelevant ECs.
> In any case, if there is a useful optimization here, it can be pursued
> later.
This makes sense.
> I changed it anyway after noting that (a) passing in the ojrelid is
> needful to be able to distinguish inner and outer joins, and
> (b) the existing comment about the join_relids input is now wrong.
> Even if it happens to not be borked for current callers, that seems
> like a mighty fragile assumption.
Agreed. This is reasonable.
> Less-hasty v2 patch attached.
I think the patch is in good shape now.
Thanks
Richard
From | Date | Subject | |
---|---|---|---|
Next Message | John Naylor | 2023-02-23 09:40:58 | Re: [PoC] Improve dead tuple storage for lazy vacuum |
Previous Message | shiy.fnst@fujitsu.com | 2023-02-23 09:29:44 | RE: Allow logical replication to copy tables in binary format |