Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bIM05-00063u-Bs for pgsql-performance@arkaria.postgresql.org; Wed, 29 Jun 2016 20:22:21 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bIM04-00064O-Qx for pgsql-performance@arkaria.postgresql.org; Wed, 29 Jun 2016 20:22:20 +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.84_2) (envelope-from ) id 1bILyP-0004F9-Gx for pgsql-performance@postgresql.org; Wed, 29 Jun 2016 20:20:37 +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.84_2) (envelope-from ) id 1bILyL-0002dD-UJ for pgsql-performance@postgresql.org; Wed, 29 Jun 2016 20:20:36 +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 u5TKKVro029848; Wed, 29 Jun 2016 16:20:31 -0400 From: Tom Lane To: devel.brain99@xoxy.net cc: pgsql-performance@postgresql.org Subject: Re: Random slow queries In-reply-to: References: Comments: In-reply-to devel.brain99@xoxy.net message dated "Wed, 29 Jun 2016 20:04:31 +0200" Date: Wed, 29 Jun 2016 16:20:31 -0400 Message-ID: <29847.1467231631@sss.pgh.pa.us> X-Pg-Spam-Score: -3.2 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org devel.brain99@xoxy.net writes: > As you can see from the logs I posted, it appears the execution plan was > cached (LOG: duration: 122006.000 ms bind cached-1453392550: select....). > Maybe those aren't processed by auto_explain? In that, "cached-1453392550" is a statement name given by the client; you'd know better than we do where it's coming from, but it has no particular significance to the server. The real information here is that what is taking 122 seconds is the BIND step of extended query protocol. That explains why auto_explain doesn't notice it; auto_explain only instruments the execution phase. Typically, what takes time in the BIND step is planning the query, so it seems like we have to conclude that something in planning is getting hung up. That doesn't get us very much closer to an explanation though :-(. Don't know if it would be practical for you at all, but if you could attach to a process that's stuck like this with a debugger and get a stack trace, that would probably be very informative. https://wiki.postgresql.org/wiki/Generating_a_stack_trace_of_a_PostgreSQL_backend regards, tom lane -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance