Re: Predicate migration on complex self joins

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Simon Riggs <simon(at)2ndQuadrant(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Predicate migration on complex self joins
Date: 2009-07-13 17:33:07
Message-ID: 26351.1247506387@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Simon Riggs <simon(at)2ndQuadrant(dot)com> writes:
> In some cases, we have SQL being submitted that has superfluous
> self-joins. An example would be

> select count(*)
> from foo1 a, foo1 b
> where a.c1 = b.c1 /* PK join */
> and a.c2 = 5
> and b.c2 = 10;

> You may well ask who would be stupid enough to write SQL like that. The
> answer is of course that it is automatically generated by an ORM.

Seems like the right answer is "fix the damn ORM". It's hard to believe
this sort of case comes up often enough to justify the cycles that would
be expended (on *every* join query) to try to recognize it.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2009-07-13 17:49:22 Re: Predicate migration on complex self joins
Previous Message Kevin Grittner 2009-07-13 17:28:09 Re: Predicate migration on complex self joins