Re: Query performance with min and filter - Mailing list pgsql-general

From Tom Lane
Subject Re: Query performance with min and filter
Date
Msg-id 3955504.1598881032@sss.pgh.pa.us
Whole thread Raw
In response to Query performance with min and filter  ("Yorwerth, Adam" <Adam.Yorwerth@tesco.com>)
List pgsql-general
"Yorwerth, Adam" <Adam.Yorwerth@tesco.com> writes:
> We seem to have found a situation where a query run using explain analyse or pgbench is incredibly fast, but run via
Javaunder load performs very poorly – we’ve checked query performance metrics for our Postgres instance and can confirm
thatit’s the query running slowly, and not a Java problem. 

Usually when people report something like this, the explanation is that
it's not actually the same query being tested in both cases.

In particular, if you're parameterizing the query in Java but substituting
constant values when running it manually, that can make a difference.

A further-afield possibility is that your application has been set up to
run with custom values of work_mem, planner cost constants, etc, which
you're failing to duplicate in the manual tests.

If all else fails, try installing auto_explain so that you can capture
the actual query plan used when the application executes this query.

            regards, tom lane



pgsql-general by date:

Previous
From: Thomas Kellerer
Date:
Subject: Re: How bad is using queries with thousands of values for operators IN or ANY?
Next
From: Thomas Boussekey
Date:
Subject: Re: When are largobject records TOASTed into pg_toast_2613?