Re: Not same plan between static and prepared query

Поиск
Список
Период
Сортировка
От Amit Kapila
Тема Re: Not same plan between static and prepared query
Дата
Msg-id 007201ce62a2$56c35930$044a0b90$@kapila@huawei.com
обсуждение исходный текст
Ответ на Not same plan between static and prepared query  (Ghislain ROUVIGNAC <ghr@sylob.com>)
Ответы Re: Not same plan between static and prepared query  ("Yuri Levinsky" <yuril@celltick.com>)
Список pgsql-performance
On Thursday, June 06, 2013 1:56 PM Ghislain ROUVIGNAC wrote:
> Hello,


> We have a strange issue related to a prepared statement.


> We have two equals queries where the sole difference is in the limit.
> - The first is hard coded with limit 500.
> - The second is prepared with limit $1 ($1 is bound to 500).


> PostgreSQL give us two different plans with a huge execution time for the
prepared query:

It can generate different plan for prepared query, because optimizer uses
default selectivity in case of bound parameters (in your case limit $1).


> We met the same behaviour with both :
> - PostgreSQL 8.4.8 on Windows 2008 (Prod)
> - PostgreSQL 8.4.8 and 8.4.17 on Windows 7 (Dev)

From PostgreSQL 9.2, it generates plan for prepared query during execution
(Execute command) as well.
So I think you will not face this problem in PostgreSQL 9.2 and above.

With Regards,
Amit Kapila.



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

Предыдущее
От: Ghislain ROUVIGNAC
Дата:
Сообщение: Not same plan between static and prepared query
Следующее
От: Kevin Grittner
Дата:
Сообщение: Re: Check Pointer