Re: Bind message

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Bind message
Дата
Msg-id 24245.1159276238@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Bind message  (Markus Schaber <schabi@logix-tt.com>)
Ответы Re: Bind message
Список pgsql-jdbc
Markus Schaber <schabi@logix-tt.com> writes:
> Don't forget that, in the current implementation, the query planner has
> no choice but planning the query without any actual parameter values,
> which is likely to give equal or worse results in most cases.

No, I think you are oversimplifying.  What the planner is supposed to do
when given a parameterized query (and no parameter value info) is to
generate a plan that won't be too terribly awful regardless of the
parameter values.  With a set of sample values, it may generate a plan
that is great for those values and utterly unusable for anything else.
Here's a simple example:

    select ... from a join b on (a.key = b.key) where a.val = ?

Given a parameter value that looks like it will match only one A row,
you will likely get a plan like this:

    Nest Loop
        Index Scan on A
            Index Cond: val = ?
        Index Scan on B
            Index Cond: b.key = a.key

which is about as fast as you can get if indeed there's only one match.
However if the parameter value matches very many A rows, this plan is
horrid.  With no value for the parameter, the planner should pick a
compromise plan (perhaps a mergejoin) that may not be as fast for the
single-match case, but will finish before doomsday in the other case.

            regards, tom lane

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

Предыдущее
От: Oliver Jowett
Дата:
Сообщение: Re: Bind message
Следующее
От: till toenges
Дата:
Сообщение: Re: bytea memory improvement