Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fQhIj-0005PZ-Jk for pgsql-general@arkaria.postgresql.org; Wed, 06 Jun 2018 22:53:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fQhIi-00059j-D3 for pgsql-general@arkaria.postgresql.org; Wed, 06 Jun 2018 22:53:08 +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 1fQhIi-00059Y-5F for pgsql-general@lists.postgresql.org; Wed, 06 Jun 2018 22:53:08 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fQhIe-0007Qs-AF for pgsql-general@postgresql.org; Wed, 06 Jun 2018 22:53:07 +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 w56MquQ1002184; Wed, 6 Jun 2018 18:52:56 -0400 From: Tom Lane To: Jerry Sievers cc: Pavel Stehule , Jeremy Finzel , Postgres General Subject: Re: Slow planning time for simple query In-reply-to: <87efhjimx7.fsf@jsievers.enova.com> References: <22136.1528312205@sss.pgh.pa.us> <87efhjimx7.fsf@jsievers.enova.com> Comments: In-reply-to Jerry Sievers message dated "Wed, 06 Jun 2018 17:13:08 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2182.1528325576.1@sss.pgh.pa.us> Date: Wed, 06 Jun 2018 18:52:56 -0400 Message-ID: <2183.1528325576@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Jerry Sievers writes: > Tom Lane writes: >> Oh, hmm, yeah it could be ye olde get_actual_variable_range() issue. >> When this happens, are there perhaps a lot of recently-dead rows at either >> extreme of the range of table1.source_id or table2.id? > We noticed the cluster of interest had a rogue physical rep slot holding > 71k WAL segments. > Dropping same slot seemed to correlate with the problem going away. > Does that sound like a plausible explanation for the observed slow > planning times? I believe the slot would hold back global xmin and thereby prevent "recently-dead" rows from becoming just plain "dead", so yeah, this observation does seem to square with the get_actual_variable_range theory. You'd still need to posit that something had recently deleted a lot of rows at the end of the range of one of those columns, though. regards, tom lane