Re: performance issue - Mailing list pgsql-jdbc

From Kris Jurka
Subject Re: performance issue
Date
Msg-id 47EB2E81.3080302@ejurka.com
Whole thread Raw
In response to performance issue  (Steven varga <varga@yorku.ca>)
Responses Re: performance issue  (Guillaume Cottenceau <gc@mnc.ch>)
List pgsql-jdbc
Steven varga wrote:
>
> having about 10^6 records in a table indexed on names and doing a
> query from psql I get response time in millisec order on the other
> hand when executing the same query through JDBC it hangs about 80
> seconds.
>
>  PreparedStatement count =
>         connection.prepareStatement("SELECT count(*) FROM
>     upc WHERE name like upper(?)||'%' ");
>

When using a PreparedStatement the server must come up with a plan that
works for all parameter values.  Since the parameter is unknown, the
generated plan doesn't use an index.  Your options are to interpolate
the parameter yourself or connect using the protocolVersion=2 URL option
which will make the driver do the interpolation prior to passing the
query on to the server.

Kris Jurka

pgsql-jdbc by date:

Previous
From: Steven varga
Date:
Subject: performance issue
Next
From: Guillaume Cottenceau
Date:
Subject: Re: performance issue