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 1oSzEX-0000Ez-6U for pgsql-general@arkaria.postgresql.org; Tue, 30 Aug 2022 11:16:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oSzEV-0007lE-IM for pgsql-general@arkaria.postgresql.org; Tue, 30 Aug 2022 11:16:39 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oSzEU-0007kt-Fc for pgsql-general@lists.postgresql.org; Tue, 30 Aug 2022 11:16:39 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oSzEP-00076d-An for pgsql-general@postgresql.org; Tue, 30 Aug 2022 11:16:38 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 80F455C0106; Tue, 30 Aug 2022 07:16:30 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Tue, 30 Aug 2022 07:16:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1661858190; x=1661944590; bh=Y TDVOClxQjh1b+8C3+a7h/DofhKFN/JPh99jXG9Kt/A=; b=oqHhBtRRpoyMJwF2T Bu589WmqT1d5LZ36hF7d7fBCzojvlgFnzbtrxznVVCowhDNme/fv1h9XtP50JIWs xkI2rKSZR7RYmxfIcEafAnk2+DLShvkcGTEKXdInpfNShmak96Rv/Lt0Uhv3WAcL 1mxs6f7RuTm4gVS0naTt+oxH9vsgTry06vk8gyDY7uxdwt+siBx8nhxgDMKMCl9e E/9Veqc+yYh1u87qwzFQOcmCwxLYBbSHwlJabACqYtrlY0fffgfaJTtWEwMsz5We 3Mucr+r8MBKZUAGOguDZIYZ2ycrLfEyGtaT9EWwW6aRFoxKIhjuZjz2v4ql93ODy ueKkw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdekfedgfeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkgggtugfgjgesthekredttddtjeenucfhrhhomheptehlvhgr rhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh eqnecuggftrfgrthhtvghrnhepvdektdffudfftdffffehfffhjeejhffgieeuueekjeek fffgudffhfduffffueevnecuffhomhgrihhnpegvnhhtvghrphhrihhsvggusgdrtghomh enucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhv hhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 30 Aug 2022 07:16:29 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 95CBB378; Tue, 30 Aug 2022 13:16:43 +0200 (CEST) Date: Tue, 30 Aug 2022 13:16:43 +0200 From: Alvaro Herrera To: Matheus Martin Cc: pgsql-general@postgresql.org Subject: Re: Missing query plan for auto_explain. Message-ID: <20220830111643.oj3cnolt3hjrxng6@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2022-Aug-30, Matheus Martin wrote: > Our Postgres recently started reporting considerably different > execution times for the same query. When executed from our JDBC > application the Postgres logs report an average execution time of 1500 > ms but when the query is manually executed through `psql` it doesn't > take longer than 50 ms. I don't know why the plan is not saved by auto_explain (maybe we're missing ExecutorEnd calls somewhere? that would be strange), but one frequent reason for queries to show different plan in JDBC than psql is the use of prepared statements. Did you try using "PREPARE yourquery(...)" and then EXPLAIN EXECUTE(...)? Sometimes that helps to recreate the original problem. (Apparently, ExecutorEnd is called from PortalCleanup; what happens with the portal for an extended-protocol query?) -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/