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 1fQevj-00053p-UU for pgsql-general@arkaria.postgresql.org; Wed, 06 Jun 2018 20:21:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fQevi-0001i2-Gl for pgsql-general@arkaria.postgresql.org; Wed, 06 Jun 2018 20:21:14 +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 1fQevh-0001hr-8p for pgsql-general@lists.postgresql.org; Wed, 06 Jun 2018 20:21:14 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fQevd-0003gW-Cc for pgsql-general@postgresql.org; Wed, 06 Jun 2018 20:21:12 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id AC81B210FE; Wed, 6 Jun 2018 16:21:07 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Wed, 06 Jun 2018 16:21:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=p/VSfj2UAPSXoEnZyd5u918VTrGan Ns4il51VHPx+0Y=; b=gESvEUw5pBFmZ7YsYb8zmyzaycszgTUvcDioGD41M5dzS oGQmswhML/X00XXFwJ1qqUGMPsZ6zN44api0ov49Q6oC+tQjoDM2otS9wU/9TP0z lQV4DLtucECV0YvGmVmmCxTOrltc6rqxzR1s3MTfu3/A6W4COjulDHYuoXRoPRYp 6NvyChtB1cvo71vGdryMVpd2fJN4PyIET0kmB6Ta1/P0ijmNDXkoTwCWAoWaMHbr 1zZWb1Lf/yNsqZJWS6mnYOma13JoUjF2/rZmdsUOS+nTbbJCiniheiUIoMksdcV/ YPZjiwPb1znEanEa9/t5KTa8i7xKCbVVgMdJkXwSQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=p/VSfj 2UAPSXoEnZyd5u918VTrGanNs4il51VHPx+0Y=; b=liNvPQ70MaB7YWCl/77pjZ QjrBnB6YtMH6TcQ1aXUcCW6tJWbmtM4YdJLHrWvENnvuIllvO2sHsIsVMLP9yqWo 3ZXYT2vwYjt471f/FAxlZGlHplSKGyNWLTNhrPGjZVFpd9Awz89lKCIfQwLMGTN1 rPqHcsXJlzo+ywvrJoWYg7tECVG9I+bTNuCAEo1UMtBEBw/tghvNMy0kvtDDQx4E U1duq2C+ZpYm+nAvlbFlX63rX90qXGnm7YTFspqW+S1sTpTXkO0b3ywAwkhCPJcS NpdnvIFyY59Qo5+XCfMzQzIXSCACVrprZmi4/Gp0l0DeUBrH2gJP9dXodVTL2wkA == X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Sender: Received: from ranger.suse (50-197-80-2-static.hfc.comcastbusiness.net [50.197.80.2]) by mail.messagingengine.com (Postfix) with ESMTPA id F407EE43E8; Wed, 6 Jun 2018 16:21:06 -0400 (EDT) Subject: Re: Slow planning time for simple query To: Jeremy Finzel , Postgres General References: From: Adrian Klaver Message-ID: <91862f3c-40ec-5aeb-c721-56713263cd06@aklaver.com> Date: Wed, 6 Jun 2018 13:21:05 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 06/06/2018 09:59 AM, Jeremy Finzel wrote: > Hello - > > 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); > > The actual execution time is sub-ms. I am trying to sort out the various references to times so could you: Show the EXPLAIN ANALYZE? and ? psql> \timing psql> SELECT * FROM table1 WHERE source_id IN (SELECT id FROM table2 WHERE customer_id = $1); > > We initially thought maybe catalog bloat?  But we were able to reindex > all of the highly churned catalog tables, and I even did VACUUM FULL on > pg_attribute and pg_statistic, to no avail. > > There are no custom settings for pg_attribute for the given tables either. > > Interestingly, the problem goes away on a SAN snapshot of the target system. > > Any ideas of what else we could try?  A PL function that caches the > query plan works, but that is just a workaround. > > Thanks! > Jeremy -- Adrian Klaver adrian.klaver@aklaver.com