From: | Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)com> |
---|---|
To: | Gourav Kumar <gourav1905(at)gmail(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: How does postgres store the join predicate for a relation in a given query |
Date: | 2017-10-16 05:13:12 |
Message-ID: | CAFjFpRcVZ82GAu7F+h8BWt+FvE22tixyQzA0Rhy4=XKNSwXp8g@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Sat, Oct 14, 2017 at 3:15 AM, Gourav Kumar <gourav1905(at)gmail(dot)com> wrote:
> Why does have_relevant_joinclause() and have_relevant_eclass_joinclause()
> return true for all possible joins for the query given below.
> Even when they have no join predicate between them.
> e.g. join between ss1 & ws3, ss2 & ws3 etc.
>
The prologues of those functions and comments within those explain that.
/*
* have_relevant_joinclause
* Detect whether there is a joinclause that involves
* the two given relations.
*
* Note: the joinclause does not have to be evaluable with only these two
* relations. This is intentional. For example consider
* SELECT * FROM a, b, c WHERE a.x = (b.y + c.z)
* If a is much larger than the other tables, it may be worthwhile to
* cross-join b and c and then use an inner indexscan on a.x. Therefore
* we should consider this joinclause as reason to join b to c, even though
* it can't be applied at that join step.
*/
/*
* have_relevant_eclass_joinclause
* Detect whether there is an EquivalenceClass that could produce
* a joinclause involving the two given relations.
*
* This is essentially a very cut-down version of
* generate_join_implied_equalities(). Note it's OK to occasionally say "yes"
* incorrectly. Hence we don't bother with details like whether the lack of a
* cross-type operator might prevent the clause from actually being generated.
*/
May be you want to see whether those comments are applicable in your
case and also see how the callers handle the return values.
--
Best Wishes,
Ashutosh Bapat
EnterpriseDB Corporation
The Postgres Database Company
From | Date | Subject | |
---|---|---|---|
Next Message | Amit Langote | 2017-10-16 05:56:06 | Re: relkind check in DefineIndex |
Previous Message | Amit Langote | 2017-10-16 02:58:30 | Re: UPDATE of partition key |