Re: Disable cross products in postgres

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Gourav Kumar <gourav1905(at)gmail(dot)com>
Cc: fabriziomello(at)gmail(dot)com, Robert Haas <robertmhaas(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Disable cross products in postgres
Date: 2017-10-13 22:13:22
Message-ID: 20532.1507932802@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Gourav Kumar <gourav1905(at)gmail(dot)com> writes:
> For e.g. I am checking for this query
> ...
> where
> and ss1.ca_county = ss2.ca_county
> and ss2.ca_county = ss3.ca_county
> and ss1.ca_county = ws1.ca_county
> and ws1.ca_county = ws2.ca_county
> and ws1.ca_county = ws3.ca_county

> It doesn't has a join predicate between ss1 and ws2 or ss1 and ws3. But
> optimizer still considers a join among them.

Sure it does, after transitive propagation of those equalities;
for instance we can derive ss1.ca_county = ws2.ca_county from
the above-quoted conditions. And it would be very stupid of the
optimizer not to consider those derived join conditions, because
they may lead to the optimal join order.

In general it's already true that the optimizer doesn't consider
clauseless joins unless there's no other choice. But this example
isn't showing such a case.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Gourav Kumar 2017-10-13 22:19:57 Re: Disable cross products in postgres
Previous Message Andres Freund 2017-10-13 21:46:41 Re: Discussion on missing optimizations