Re: [PERFORM] Slow query in JDBC - Mailing list pgsql-performance

From Jeff Janes
Subject Re: [PERFORM] Slow query in JDBC
Date
Msg-id CAMkU=1wHLUx19hBkvWVgppo0Dk=HVHm7wU9Tfsx5Y_jRSkV-Hw@mail.gmail.com
Whole thread Raw
In response to Re: [PERFORM] Slow query in JDBC  (Subramaniam C <subramaniam31784@gmail.com>)
Responses Re: [PERFORM] Slow query in JDBC
List pgsql-performance
On Thu, Sep 28, 2017 at 2:59 AM, Subramaniam C <subramaniam31784@gmail.com> wrote:
First output show the output when the query is executed from sql command line. The second output show when it is executed from the application. AS per the output it is clear that the when the query is executed through JDBC its not using the index (health_index) instead its doing sequence scan. Please let us know how this issue can be resolved from JDBC?

1.)


                                ->  Index Only Scan using health_index on health_timeseries_table  (cost=0.56..421644.56 rows=1558800 width=24)

                                      Index Cond: (("timestamp" >= '1505989186834'::bigint) AND ("timestamp" <= '1505990086834'::bigint))

 

2.)


                                      ->  Seq Scan on health_timeseries_table  (cost=0.00..267171.00 rows=1005634 width=24)

                                            Filter: (("timestamp" >= '1505989500000'::bigint) AND ("timestamp" <= '1505990400000'::bigint))



Those are different queries, so it is not terribly surprising it might choose a different plan.

For this type of comparison, you need to compare identical queries, including parameter.

Cheers,

Jeff

pgsql-performance by date:

Previous
From: Subramaniam C
Date:
Subject: Re: [PERFORM] Slow query in JDBC
Next
From: Subramaniam C
Date:
Subject: Re: [PERFORM] Slow query in JDBC