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 1fQbyy-00012K-Nt for pgsql-general@arkaria.postgresql.org; Wed, 06 Jun 2018 17:12:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fQbyw-00031U-7g for pgsql-general@arkaria.postgresql.org; Wed, 06 Jun 2018 17:12:22 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fQbyv-00030n-S3 for pgsql-general@lists.postgresql.org; Wed, 06 Jun 2018 17:12:22 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fQbyp-0001Hh-8e for pgsql-general@postgresql.org; Wed, 06 Jun 2018 17:12:20 +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 w56HCDWP013757; Wed, 6 Jun 2018 13:12:13 -0400 From: Tom Lane To: Jeremy Finzel cc: Postgres General Subject: Re: Slow planning time for simple query In-reply-to: References: Comments: In-reply-to Jeremy Finzel message dated "Wed, 06 Jun 2018 11:59:23 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <13755.1528305133.1@sss.pgh.pa.us> Date: Wed, 06 Jun 2018 13:12:13 -0400 Message-ID: <13756.1528305133@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Jeremy Finzel writes: > 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); Hm. Is this the first query executed in a session? If so maybe it's got something to do with populating caches and other session spin-up overhead. Another theory is it's some sort of locking issue. Turning on log_lock_waits, and setting deadlock_timeout to say 100ms, would help in investigating that. regards, tom lane