Re: Different query plans when running through application - Mailing list pgsql-admin

From Craig James
Subject Re: Different query plans when running through application
Date
Msg-id CAFwQ8rei42VCE1ohcXB2-kzRMqJtC3nbkYeXT8UmULgxtkui9A@mail.gmail.com
Whole thread Raw
In response to Different query plans when running through application  (srinivas oguri <srinivasoguri7@gmail.com>)
List pgsql-admin
You should be more specific -- show the Java code that you are using. My guess (and I'm not an expert) is that you're using a Java variable binding of some sort that causes the planner to create a plan without knowing what the specific values are that are being bound to the SQL. When you execute the plan in psql, you're putting the values directly in so the planner can figure it out.

But without seeing your Java code, it's just a wild guess.

Craig

On Tue, Oct 29, 2019 at 6:46 AM srinivas oguri <srinivasoguri7@gmail.com> wrote:
Hi team,

We have seen a query running from application(Java based) is taking wrong plan. It is a partitioned table, when the query is executed it is scanning all partitions. When I execute the query manually from psql it is scanning the right partition. 

1. Stats are up to date (we have scheduled a hourly job to analyze the table partitions which are used in the query along with tuning autovacuum process).
2. We are using Amazon aurora with 9.6.9 version.

Please help me in troubleshooting this.

Thanks
Srinivas


--
---------------------------------
Craig A. James
Chief Technology Officer
eMolecules, Inc.
3430 Carmel Mountain Road, Suite 250
San Diego, CA 92121
---------------------------------

pgsql-admin by date:

Previous
From: srinivas oguri
Date:
Subject: Different query plans when running through application
Next
From: "David G. Johnston"
Date:
Subject: Re: the difference between psql , createdb, dropuser