Re: JDBC/Stored procedure performance issue

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: JDBC/Stored procedure performance issue
Дата
Msg-id 6915.1201553513@sss.pgh.pa.us
обсуждение исходный текст
Ответ на JDBC/Stored procedure performance issue  (Claire McLister <mclister@zeesource.net>)
Ответы Re: JDBC/Stored procedure performance issue  (Matthew Lunnon <mlunnon@rwa-net.co.uk>)
Re: JDBC/Stored procedure performance issue  (Claire McLister <mclister@zeesource.net>)
Список pgsql-performance
Claire McLister <mclister@zeesource.net> writes:
> When I do an EXPLAIN ANALYZE on one query that returns 3261 rows, it
> executes in a reasonable 159ms:
> ...
> If I issue the same query over JDBC or use a PSQL stored procedure, it
> takes over 3000 ms, which, of course is unacceptable!

I suspect that the problem is with "groupid = $1" instead of
"groupid = 57925".  The planner is probably avoiding an indexscan
in the parameterized case because it's guessing the actual value will
match so many rows as to make a seqscan faster.  Is the distribution
of groupid highly skewed?  You might get better results if you increase
the statistics target for that column.

Switching to something newer than 7.4.x might help too.  8.1 and up
support "bitmap" indexscans which work much better for large numbers
of hits, and correspondingly the planner will use one in cases where
it wouldn't use a plain indexscan.

            regards, tom lane

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

Предыдущее
От: Arjen van der Meijden
Дата:
Сообщение: Re: 8x2.5" or 6x3.5" disks
Следующее
От: "Merlin Moncure"
Дата:
Сообщение: Re: Hard Drive Usage for Speeding up Big Queries