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

Поиск
Список
Период
Сортировка
От Markus Bertheau
Тема Re: response time when querying via JDBC and via psql differs
Дата
Msg-id 684362e10802250310m48c45cb3lad3e70312ef4b3b6@mail.gmail.com
обсуждение исходный текст
Ответ на response time when querying via JDBC and via psql differs  ("Pavel Rotek" <pavel.rotek@gmail.com>)
Ответы Re: response time when querying via JDBC and via psql differs  ("Nikolas Everett" <nik9000@gmail.com>)
Список pgsql-performance
2008/2/25, Pavel Rotek <pavel.rotek@gmail.com>:
>   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??

Most likely the problem is that the JDBC driver uses prepared statements, in
which the query is planned withouth the concrete argument value. For like only
patterns that don't start with % or _ can use the index. Without the argument
value PostgreSQL can't tell whether that is the case, so it takes the safe
route and chooses a sequential scan.

to solve this particular problem, you have to convince jdbc to not use a
prepared statement for this particular query.

Markus

В списке pgsql-performance по дате отправления:

Предыдущее
От: "Pavel Rotek"
Дата:
Сообщение: response time when querying via JDBC and via psql differs
Следующее
От: Matthew
Дата:
Сообщение: Re: CORRECTION to msg 'loading same instance of dump to two different servers simultaneously'