From: Tom Lane <tgl@sss.pgh.pa.us>
To: Moshe Jacobson <moshe@neadwerx.com>
Cc: pgsql-bugs@postgresql.org
Cc: Robert Mowlavi <robert@neadwerx.com>
Cc: Chris Autry <chris@neadwerx.com>
Subject: Re: LEFT JOINs not optimized away when not needed
Date: Tue, 08 Jul 2014 17:40:00 -0400
Message-ID: <2517.1404855600@sss.pgh.pa.us> (raw)
In-Reply-To: <CAJ4CxLkYMm6wV-5yhGtRVXOHsP-9CkXafhsT=+2D6-9dkMueiA@mail.gmail.com>
References: <CAJ4CxLkrWctbEhoshWvxnEDi9=PvoDbWzdf5OJqvfv840Hv0_Q@mail.gmail.com>
<8401.1404832771@sss.pgh.pa.us>
<CAJ4CxLnRUjVAsj+KuWzDtRotsuR7tjRqsAmtsEaL1vwSqQRkog@mail.gmail.com>
<30516.1404848833@sss.pgh.pa.us>
<CAJ4CxLnPdAJ9aHTe65TLBN1X2Xdb3g1Q0-hKt2g7+1VNadGWDw@mail.gmail.com>
<709.1404852028@sss.pgh.pa.us>
<CAJ4CxLkYMm6wV-5yhGtRVXOHsP-9CkXafhsT=+2D6-9dkMueiA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
Moshe Jacobson <moshe@neadwerx.com> writes:
> On Tue, Jul 8, 2014 at 4:40 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> No. There is nothing about GROUP BY in the join removal logic.
> OK. Thank you. Is this something that would make sense to add?
Dunno. I don't recall any previous requests for such a thing, so I'd not
be inclined to add it unless it can be done very cheaply (in terms of both
code and runtime). However, it seems like that might possibly be the
case, if someone wanted to pursue making a patch. The existing logic
to check for "no references above the join" would serve fine to exclude
grouping by the inner relation, so it might only be necessary to check
that the query has GROUP BY/DISTINCT at all (and, I guess, no aggregates
or window functions). Or possibly I'm missing something.
> More importantly, do you have any suggestions on how we can improve the
> speed of our views when only a couple of columns are selected from them?
Well, I'd stay away from twenty-seven-way joins if I were you :-(.
That's a recipe for pain. Perhaps denormalizing your schema a bit would
help there.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, moshe@neadwerx.com, robert@neadwerx.com, chris@neadwerx.com
Subject: Re: LEFT JOINs not optimized away when not needed
In-Reply-To: <2517.1404855600@sss.pgh.pa.us>
References: <CAJ4CxLkrWctbEhoshWvxnEDi9=PvoDbWzdf5OJqvfv840Hv0_Q@mail.gmail.com> <8401.1404832771@sss.pgh.pa.us> <CAJ4CxLnRUjVAsj+KuWzDtRotsuR7tjRqsAmtsEaL1vwSqQRkog@mail.gmail.com> <30516.1404848833@sss.pgh.pa.us> <CAJ4CxLnPdAJ9aHTe65TLBN1X2Xdb3g1Q0-hKt2g7+1VNadGWDw@mail.gmail.com> <709.1404852028@sss.pgh.pa.us> <CAJ4CxLkYMm6wV-5yhGtRVXOHsP-9CkXafhsT=+2D6-9dkMueiA@mail.gmail.com> <2517.1404855600@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox