Re: prepared statements suboptimal?

Поиск
Список
Период
Сортировка
От Reg Me Please
Тема Re: prepared statements suboptimal?
Дата
Msg-id 200711071238.28088.regmeplease@gmail.com
обсуждение исходный текст
Ответ на prepared statements suboptimal?  (rihad <rihad@mail.ru>)
Список pgsql-general
Il Wednesday 07 November 2007 12:25:46 rihad ha scritto:
> I don't understand why postgres couldn't plan this:
> SELECT foo.e, foo.f
> FROM foo
> WHERE pk=$1 AND b=$2 AND status='1' AND c <= $3;
>
> to be later executed any slower than
>
> SELECT foo.e, foo.f
> FROM foo
> WHERE pk='abcabc' AND b='13' AND status='1' AND c <= '2007-11-20 13:14:15';

One solution is that the planner will work when it will see the query.
At that time the comparisons are all against unknown values.

Try the same with dyamical SQL, that is you dynamically build by placing the
current values instead of the $1, $2 and $3 placeholders.
In this case the planner will see the query with all current real values.
Then you execute it and compare the timings. Maybe you get better scores:
there's no warranty for better performances becasue you are going to send
the whole query again and again to the planner.

Of course you need a plpgsql function for this.
--
Reg me Please

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

Предыдущее
От: Simon Riggs
Дата:
Сообщение: Re: Postgresql simple query performance question
Следующее
От: Simon Riggs
Дата:
Сообщение: Re: Exclusive Locks Taken on User Tables?