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 1idErN-0003Ov-OU for pgsql-general@arkaria.postgresql.org; Fri, 06 Dec 2019 14:45:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1idErM-0006RP-Dw for pgsql-general@arkaria.postgresql.org; Fri, 06 Dec 2019 14:45:32 +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 1idErM-0006RI-0N for pgsql-general@lists.postgresql.org; Fri, 06 Dec 2019 14:45:32 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1idErJ-0006wv-Aa for pgsql-general@lists.postgresql.org; Fri, 06 Dec 2019 14:45:30 +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 xB6EjOj6004903; Fri, 6 Dec 2019 09:45:24 -0500 From: Tom Lane To: =?UTF-8?Q?Mladen_Marinovi=C4=87?= cc: pgsql-general@lists.postgresql.org Subject: Re: Slow planing... In-reply-to: References: Comments: In-reply-to =?UTF-8?Q?Mladen_Marinovi=C4=87?= message dated "Fri, 06 Dec 2019 14:50:22 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4901.1575643524.1@sss.pgh.pa.us> Date: Fri, 06 Dec 2019 09:45:24 -0500 Message-ID: <4902.1575643524@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk =?UTF-8?Q?Mladen_Marinovi=C4=87?= writes: > After a couple of hours of trying different stuff, set enable_mergejoin = > off made the planning time look better: Planning time: 0.322 ms > Any ideas why this helps? Hmm, possibly because it's reducing the number of calls to get_actual_variable_range. Do you have an indexed column, with a lot of recently-dead entries at the end of its range, that is a join key in the slow query? If so, you might be hitting the problem that was fixed (not for 9.6) here: https://git.postgresql.org/gitweb/?p=postgresql.git&a=commitdiff&h=3ca930fc3 regards, tom lane