From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Matheus Martin <matheus.martin@voidbridge.com>
Cc: pgsql-general@postgresql.org
Subject: Re: Missing query plan for auto_explain.
Date: Tue, 30 Aug 2022 13:16:43 +0200
Message-ID: <20220830111643.oj3cnolt3hjrxng6@alvherre.pgsql> (raw)
In-Reply-To: <CAB_m0bG9BTFSg_n9EoE+J_wKpHjsYhYstCm2sGCkEQ=mEcaG6w@mail.gmail.com>
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/
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: alvherre@alvh.no-ip.org, matheus.martin@voidbridge.com
Subject: Re: Missing query plan for auto_explain.
In-Reply-To: <20220830111643.oj3cnolt3hjrxng6@alvherre.pgsql>
References: <CAB_m0bG9BTFSg_n9EoE+J_wKpHjsYhYstCm2sGCkEQ=mEcaG6w@mail.gmail.com> <20220830111643.oj3cnolt3hjrxng6@alvherre.pgsql>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox