Re: Query performance with min and filter

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Yorwerth, Adam" <Adam(dot)Yorwerth(at)tesco(dot)com>
Cc: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>, "Cianciaruso, Lorenzo" <lorenzo(dot)cianciaruso(at)tesco(dot)com>
Subject: Re: Query performance with min and filter
Date: 2020-08-31 13:37:12
Message-ID: 3955504.1598881032@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Yorwerth, Adam" <Adam(dot)Yorwerth(at)tesco(dot)com> writes:
> We seem to have found a situation where a query run using explain analyse or pgbench is incredibly fast, but run via Java under load performs very poorly – we’ve checked query performance metrics for our Postgres instance and can confirm that it’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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Boussekey 2020-08-31 14:01:34 Re: When are largobject records TOASTed into pg_toast_2613?
Previous Message Thomas Kellerer 2020-08-31 11:29:02 Re: How bad is using queries with thousands of values for operators IN or ANY?