Re: response time when querying via JDBC and via psql differs

From: valgog <valgog(at)gmail(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: response time when querying via JDBC and via psql differs
Date: 2008-02-26 13:26:52
Message-ID: a251efe3-fec1-4041-998b-12610159f6e7@i7g2000prf.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Do not use setString() method to pass the parameter to the
PreparedStatement in JDBC. Construct an SQL query string as you write
it here and query the database with this new SQL string. This will
make the planner to recreate a plan every time for every new SQL
string per session (that is not usually good) but it will make the
planner to choose a correct plan.

-- Valentine Gogichashvili

On Feb 25, 11:06 am, pavel(dot)ro(dot)(dot)(dot)(at)gmail(dot)com ("Pavel Rotek") wrote:
> Hi all,
>
> i have strange problem with performance in PostgreSQL (8.1.9). My problem
> shortly:
>
> I'm using postgreSQL via JDBC driver (postgresql-8.1-404.jdbc3.jar) and
> asking the database for search on table with approximately 3 000 000
> records.
> I have created functional index table(lower(href) varchar_pattern_ops)
> because of lower case "like" searching. When i ask the database directly
> from psql, it returns result in 0,5 ms, but when i put the same command via
> jdbc driver, it returns in 10 000 ms. Where can be the problem?? Any problem
> with PostgreSQL tuning??
>
> The command is
> select df.id as id, df.c as c, df.href as href, df.existing as existing,
> df.filesize as filesize from documentfile df where (lower(href) like
> 'aba001!_2235800001.djvu' escape '!' ) order by id limit 1 Thank you very
> much for any help,
>
> Kind regards,
>
> Pavel Rotek

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Laurent Raufaste 2008-02-26 15:19:03 PG planning randomly ?
Previous Message Dimitri Fontaine 2008-02-26 12:08:53 multi-threaded pgloader needs your tests