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 1hkWWF-0007Fe-Lu for pgsql-general@arkaria.postgresql.org; Mon, 08 Jul 2019 16:29:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hkWWE-0001cH-HS for pgsql-general@arkaria.postgresql.org; Mon, 08 Jul 2019 16:29:34 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hkWWE-0001cA-8Q for pgsql-general@lists.postgresql.org; Mon, 08 Jul 2019 16:29:34 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hkWWC-0002Jh-6c for pgsql-general@lists.postgresql.org; Mon, 08 Jul 2019 16:29:33 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x68GTSFB001832; Mon, 8 Jul 2019 12:29:28 -0400 From: Tom Lane To: Andrew Gierth cc: Tom Mercha , "pgsql-general\@lists.postgresql.org" Subject: Re: Measuring the Query Optimizer Effect: Turning off the QO? In-reply-to: <87muho5x24.fsf@news-spur.riddles.org.uk> References: <20762.1562549204@sss.pgh.pa.us> <87muho5x24.fsf@news-spur.riddles.org.uk> Comments: In-reply-to Andrew Gierth message dated "Mon, 08 Jul 2019 17:14:51 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1830.1562603368.1@sss.pgh.pa.us> Date: Mon, 08 Jul 2019 12:29:28 -0400 Message-ID: <1831.1562603368@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andrew Gierth writes: > "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. Ah, right, -ENOCAFFEINE. What from_collapse_limit really does is prevent flattening sub-SELECTs when doing so would add more join-order freedom in the parent query. But ignoring sub-SELECTs, using explicit JOIN syntax with join_collapse_limit=1 will let you control the join order. regards, tom lane