Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f0Vge-0007RT-6o for pgsql-performance@arkaria.postgresql.org; Mon, 26 Mar 2018 17:13:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f0Vgd-0007fG-36 for pgsql-performance@arkaria.postgresql.org; Mon, 26 Mar 2018 17:13:35 +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_SHA384:256) (Exim 4.89) (envelope-from ) id 1f0Vgc-0007f3-SA for pgsql-performance@lists.postgresql.org; Mon, 26 Mar 2018 17:13:34 +0000 Received: from mx2.mailbox.org ([80.241.60.215]) by magus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1f0VgV-0002aP-O3 for pgsql-performance@lists.postgresql.org; Mon, 26 Mar 2018 17:13:34 +0000 Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id 624A840F6C; Mon, 26 Mar 2018 19:13:24 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter01.heinlein-hosting.de (spamfilter01.heinlein-hosting.de [80.241.56.115]) (amavisd-new, port 10030) with ESMTP id sCcMqI0zImnG; Mon, 26 Mar 2018 19:13:22 +0200 (CEST) Message-ID: <1522084401.3179.25.camel@cybertec.at> Subject: Re: Should from_collapse be switched off? (queries 10 times faster) From: Laurenz Albe To: Peter Cc: pgsql-performance@lists.postgresql.org, Tom Lane Date: Mon, 26 Mar 2018 19:13:21 +0200 In-Reply-To: <20180326103612.GA16180@gate.oper.dinoex.org> References: <20180323100308.GA1188@gate.oper.dinoex.org> <1521805295.2471.40.camel@cybertec.at> <18405.1521814459@sss.pgh.pa.us> <20180323173658.GA58069@gate.oper.dinoex.org> <1521954728.2350.24.camel@cybertec.at> <20180326103612.GA16180@gate.oper.dinoex.org> Organization: Cybertec Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Peter wrote: > ! Your reported execution times don't match the time reported in the > ! EXPLAIN output... > > Should these match? > It seems the EXPLAIN (ANALYZE, BUFFERS) does additional things, not > just execute the query. True. I had assumed you were speaking about the duration of the EXPLAIN (ANALYZE). > ! Setting "enable_nestloop = off" is as coarse as forcing "from_collapse = 1" > ! and will negatively impact other queries - if it helps at all. > > Since this query is already put into a function, I found I can easily > set from_collapse=1 only for this function, by means of "ALTER > FUNCTION ... SET ...", so it does only influence this query. > It seems this is the most straight-forward solution here. It is an option, although not one that makes one happy. You might have to revisit the decision if the data distribution changes and the chosen query plan becomes inefficient. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com