Re: parameterized limit statements

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: parameterized limit statements
Дата
Msg-id 21070.1131385416@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: parameterized limit statements  ("Merlin Moncure" <merlin.moncure@rcsonline.com>)
Ответы Re: parameterized limit statements  (Csaba Nagy <nagy@ecircle-ag.com>)
Список pgsql-hackers
"Merlin Moncure" <merlin.moncure@rcsonline.com> writes:
> The statements are invariably in form of
> select a,b,c,d from t
>     where a >= $1 and 
>         (a >  $1 or  b >= $2) and 
>         (a >  $1 or  b >  $2 or  c >= $3) and 
>         (a >  $1 or  b >  $2 or  c >  $3 or  d >  $4) 
>     order by a, b, c, d limit $5;
>                                 ^^
> If I hardcode $5 to any sub-ridiculous value, I get a proper index plan.
> Does your patch assume a limit of 1 or 10% of table rows?

If it doesn't have a value for the parameter, it'll assume 10% of table
rows, which is what it's done for a long time if the LIMIT isn't
reducible to a constant.

I suspect the real issue here is that whatever you are doing doesn't
give the planner a value to use for the parameter.  IIRC, at the moment
the only way that that happens is if you use the unnamed-statement
variation of the Parse/Bind/Execute protocol.
        regards, tom lane


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

Предыдущее
От: "Merlin Moncure"
Дата:
Сообщение: Re: parameterized limit statements
Следующее
От: "Merlin Moncure"
Дата:
Сообщение: Re: parameterized limit statements