Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hkWI9-0006w0-0P for pgsql-general@arkaria.postgresql.org; Mon, 08 Jul 2019 16:15:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hkWI7-0004iv-Rm for pgsql-general@arkaria.postgresql.org; Mon, 08 Jul 2019 16:14:59 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hkWI7-0004id-F2 for pgsql-general@lists.postgresql.org; Mon, 08 Jul 2019 16:14:59 +0000 Received: from lungold.riddles.org.uk ([82.68.208.19]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hkWI4-00024H-JC for pgsql-general@lists.postgresql.org; Mon, 08 Jul 2019 16:14:58 +0000 Received: from [192.168.127.1] (port=52957 helo=caithnard.riddles.org.uk) by lungold.riddles.org.uk with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.88 (FreeBSD)) (envelope-from ) id 1hkWI0-0002xe-2A; Mon, 08 Jul 2019 16:14:52 +0000 Received: from [127.0.0.1] (port=51808 helo=caithnard.riddles.org.uk) by caithnard.riddles.org.uk with esmtp (Exim 4.89 (FreeBSD)) (envelope-from ) id 1hkWHz-0002Hs-Bg; Mon, 08 Jul 2019 16:14:51 +0000 From: Andrew Gierth To: Tom Lane Cc: Tom Mercha , "pgsql-general\@lists.postgresql.org" Subject: Re: Measuring the Query Optimizer Effect: Turning off the QO? In-Reply-To: <20762.1562549204@sss.pgh.pa.us> (Tom Lane's message of "Sun, 07 Jul 2019 21:26:44 -0400") Message-ID: <87muho5x24.fsf@news-spur.riddles.org.uk> References: <20762.1562549204@sss.pgh.pa.us> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (berkeley-unix) Date: Mon, 08 Jul 2019 17:14:51 +0100 MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk >>>>> "Tom" == Tom Lane 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)