pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Tom Mercha <mercha_t@hotmail.com>
Cc: pgsql-general\@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Measuring the Query Optimizer Effect: Turning off the QO?
Date: Mon, 08 Jul 2019 17:14:51 +0100
Message-ID: <87muho5x24.fsf@news-spur.riddles.org.uk> (raw)
In-Reply-To: <20762.1562549204@sss.pgh.pa.us>
References: <AM6PR04MB5544CCC486DA6B21968A1217F4F70@AM6PR04MB5544.eurprd04.prod.outlook.com>
	<20762.1562549204@sss.pgh.pa.us>

>>>>> "Tom" == Tom Lane <tgl@sss.pgh.pa.us> writes:

 Tom> Two I'd particularly draw your attention to are
 Tom> join_collapse_limit and from_collapse_limit --- if you set both to
 Tom> 1, that'll effectively disable searching for a good join order,
 Tom> causing the join order to match the syntactic structure of the
 Tom> FROM clause. For instance "FROM a,b,c" will always be done by
 Tom> joining a to b first

FROM a,b,c can always be planned in any join order. If you want to force
the join order you have to set join_collapse_limit=1 AND write it as
FROM a JOIN b ON ... JOIN c ON ...

For an example, try:

explain select * from onek o1, tenk1 t, onek o2
         where o1.unique1=t.unique1 and t.unique1=o2.unique1
           and o1.unique2<10 and o2.unique2<10;

which (at least for me) joins o1 and o2 together first even with the
collapse limits set to 1.

-- 
Andrew (irc:RhodiumToad)





view thread (16+ messages)  latest in thread

Message-ID: <87muho5x24.fsf@news-spur.riddles.org.uk>
Permalink:  ../87muho5x24.fsf@news-spur.riddles.org.uk/
Also on:    postgresql.org/message-id/87muho5x24.fsf@news-spur.riddles.org.uk

 · 

reply

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-general@postgresql.org
  Cc: andrew@tao11.riddles.org.uk, tgl@sss.pgh.pa.us, mercha_t@hotmail.com
  Subject: Re: Measuring the Query Optimizer Effect: Turning off the QO?
  In-Reply-To: <87muho5x24.fsf@news-spur.riddles.org.uk>
  References: <AM6PR04MB5544CCC486DA6B21968A1217F4F70@AM6PR04MB5544.eurprd04.prod.outlook.com> <20762.1562549204@sss.pgh.pa.us> <87muho5x24.fsf@news-spur.riddles.org.uk>

* 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