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 15:47:13 -0400
Message-ID: <30516.1404848833@sss.pgh.pa.us> (raw)
In-Reply-To: <CAJ4CxLnRUjVAsj+KuWzDtRotsuR7tjRqsAmtsEaL1vwSqQRkog@mail.gmail.com>
References: <CAJ4CxLkrWctbEhoshWvxnEDi9=PvoDbWzdf5OJqvfv840Hv0_Q@mail.gmail.com>
<8401.1404832771@sss.pgh.pa.us>
<CAJ4CxLnRUjVAsj+KuWzDtRotsuR7tjRqsAmtsEaL1vwSqQRkog@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 11:19 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> What's your setting of join_collapse_limit, and if it's less than
>> 27, does raising it fix this query?
> We raised it to 30 and restarted postgres but the query plan still touched
> all of the tables.
All of the tables? Your upthread EXPLAIN result (which I duplicated here)
shows it touching only nine of the 27 tables. AFAICS, the eight
un-removed joins are either joining to non-unique keys, or can't be
removed because their tables are needed to provide joining columns for
un-removable joins.
My thought that join_collapse_limit might matter was incorrect --
I was thinking that remove_useless_joins() was invoked on subproblems,
but actually it considers the whole jointree. This is borne out by
experimentation; changing it doesn't change the set of removed joins
in this example. (Which is a good thing because you really didn't want
to run with a collapse_limit as high as 30.)
So it looks to me like it's operating as intended.
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: <30516.1404848833@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>
* 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