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 1fQggN-0003LV-Eo for pgsql-general@arkaria.postgresql.org; Wed, 06 Jun 2018 22:13:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fQggL-0005Mv-UT for pgsql-general@arkaria.postgresql.org; Wed, 06 Jun 2018 22:13:29 +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 1fQggL-0005Mb-M2 for pgsql-general@lists.postgresql.org; Wed, 06 Jun 2018 22:13:29 +0000 Received: from resqmta-ch2-06v.sys.comcast.net ([2001:558:fe21:29:69:252:207:38]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fQggI-0006NB-3m for pgsql-general@postgresql.org; Wed, 06 Jun 2018 22:13:28 +0000 Received: from resomta-ch2-12v.sys.comcast.net ([69.252.207.108]) by resqmta-ch2-06v.sys.comcast.net with ESMTP id QeCwfqtgdN6xcQggDfNP0b; Wed, 06 Jun 2018 22:13:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20161114; t=1528323201; bh=DhCxgbTWY6PPulmoUywlQhhwhAKyFqez3T+5Loo0eVs=; h=Received:Received:Received:From:To:Subject:Date:Message-ID: MIME-Version:Content-Type; b=WJcBfVSk3vK9inldSLYyQQpCCntQ9ULgQfG39TwkbdCXORy6hTiamo80fi6PzRYqs 5zs8pMkDf6bUHv0cwi8wsxsvM4kRQxEFcfFn/klimSKhIvVtOy1Sql8V1qW1GIWe6V uF/KDbBM9i/mvgHW0DL/rzTZ9tldfgqwgLz/Vx6OXwxulOYyciognYdS42jmgZExcN e07/6xp69jcFasMKJIjzTWKTi7CnoUL/AycVxAvwIC5RQecjl+l0uw3fNoK0fZtXvA 7HtQwGODSBfApAtuXEmUMEmojovLqItt/HZKhG2r/n7maH3/3U/z83iLIt8V0+r0z4 t/6aM0W5GrauQ== Received: from jsievers.comcast.net ([12.187.116.132]) by resomta-ch2-12v.sys.comcast.net with ESMTPA id Qgg0fflurJxqiQgg0fGL3u; Wed, 06 Jun 2018 22:13:18 +0000 Received: from jsievers.enova.com (localhost [127.0.0.1]) by jsievers.comcast.net (Postfix) with ESMTP id 8EFFC260056; Wed, 6 Jun 2018 17:13:08 -0500 (CDT) From: Jerry Sievers To: Tom Lane Cc: Pavel Stehule , Jeremy Finzel , Postgres General Subject: Re: Slow planning time for simple query References: <22136.1528312205@sss.pgh.pa.us> Date: Wed, 06 Jun 2018 17:13:08 -0500 In-Reply-To: <22136.1528312205@sss.pgh.pa.us> (Tom Lane's message of "Wed, 06 Jun 2018 15:10:05 -0400") Message-ID: <87efhjimx7.fsf@jsievers.enova.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-CMAE-Envelope: MS4wfAk6vTxIkWDuFnDlXvmKuEmM/OXosfsOaHevT/9tauvIfZMmya4VEKPcnkHNL5XU/JrL/dUE33xP3ggH1ubi0uBDOV70d2GywQvVXBI/JqpWzqGhQI6L gsZ62rTi4RxmhtZzBvOVO45YksAWXlvB5gN2mUkMh7rrlBcVzlZvkUfEgh/rfmUwViJm6FOhgXddvzYk51Ixvz/oTISfhsZMkT9HuMtxncFVhPz/ZcWjVB51 How/VG/auCJhzHQHqyxK9OT4vxu7O2IpMVIp2Y6CJFtI+/xvZPwH8ycF9Gz8WOpA List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Tom Lane writes: > Pavel Stehule writes: > >> 2018-06-06 18:59 GMT+02:00 Jeremy Finzel : >>> We have an odd scenario on one of our OLTP systems, which behaves the same >>> way on a streamer, of a 700-1000ms planning time for a query like this: >>> SELECT * >>> FROM table1 >>> WHERE source_id IN (SELECT id FROM table2 WHERE customer_id = $1); > >> more times I seen similar issue based on bloated indexes on table - pg in >> planning time detect min max from possible indexes > > 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? Thx > We made a fix last year to improve that: > https://git.postgresql.org/gitweb/?p=postgresql.git&a=commitdiff&h=3ca930fc3 > but it wasn't back-patched. > > regards, tom lane > > -- Jerry Sievers Postgres DBA/Development Consulting e: postgres.consulting@comcast.net p: 312.241.7800