Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jvSq2-0006uW-56 for pgsql-general@arkaria.postgresql.org; Tue, 14 Jul 2020 21:51:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jvSpy-0000m1-Vh for pgsql-general@arkaria.postgresql.org; Tue, 14 Jul 2020 21:51:42 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jvSpy-0000lu-OI for pgsql-general@lists.postgresql.org; Tue, 14 Jul 2020 21:51:42 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jvSpw-0003Gc-KE for pgsql-general@postgresql.org; Tue, 14 Jul 2020 21:51:41 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 06ELpcRj2961874; Tue, 14 Jul 2020 17:51:38 -0400 From: Tom Lane To: =?UTF-8?Q?Eudald_Valc=C3=A0rcel_Lacasa?= cc: pgsql-general@postgresql.org Subject: Re: Issue executing query from container In-reply-to: References: Comments: In-reply-to =?UTF-8?Q?Eudald_Valc=C3=A0rcel_Lacasa?= message dated "Tue, 14 Jul 2020 22:25:07 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2961872.1594763498.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 14 Jul 2020 17:51:38 -0400 Message-ID: <2961873.1594763498@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk =3D?UTF-8?Q?Eudald_Valc=3DC3=3DA0rcel_Lacasa?=3D writes: > I'm running a docker container that executes a php script running a > sequence of queries. > One of the queries gets stuck (takes more than 2 hours in execution, > active in pg_stat_activity). > The query is executed with a JOIN between a FOREIGN TABLE and a local ta= ble. > Executing this query from the psql console takes less than 5 seconds to = resolve. > If I execute the query from the container created, manually, it > resolves as well within 5 seconds. > Can anyone guide me in a way I can troubleshoot what is causing the > query to get stuck? It's a very good bet that it's something about the query being parameterized or not. You could try installing auto_explain to compare the plans that are generated. regards, tom lane