Re: Different query plans when running through application

From: Craig James <cjames(at)emolecules(dot)com>
To: srinivas oguri <srinivasoguri7(at)gmail(dot)com>
Cc: pgsql-admin(at)lists(dot)postgresql(dot)org
Subject: Re: Different query plans when running through application
Date: 2019-10-29 15:41:32
Message-ID: CAFwQ8rei42VCE1ohcXB2-kzRMqJtC3nbkYeXT8UmULgxtkui9A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)gmail(dot)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
---------------------------------

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message David G. Johnston 2019-10-29 16:37:29 Re: the difference between psql , createdb, dropuser
Previous Message srinivas oguri 2019-10-29 13:46:09 Different query plans when running through application