Re: Generic Plans for Prepared Statement are 158155 times slowerthan Custom Plans

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: Generic Plans for Prepared Statement are 158155 times slowerthan Custom Plans
Дата
Msg-id 20190429133607.3jh7bqx4vznuhok7@momjian.us
обсуждение исходный текст
Ответ на Generic Plans for Prepared Statement are 158155 times slower thanCustom Plans  ("Naik, Sameer" <Sameer_Naik@bmc.com>)
Ответы Re: Generic Plans for Prepared Statement are 158155 times slower than Custom Plans
Список pgsql-performance
On Mon, Apr 29, 2019 at 10:36:20AM +0000, Naik, Sameer wrote:
> Hi,
> 
> Since Postgres 9.2, for prepared statements, the CBO automatically switches
> from Custom Plan to Generic plan on the sixth iteration (reference backend/
> utils/cache/plancache.c).

This is not totally true.  The PREPARE manual page for PG 11 says:

       Prepared statements can use generic plans rather than re-planning
       with each set of supplied EXECUTE values. This occurs immediately
       for prepared statements with no parameters; otherwise it occurs
       only after five or more executions produce plans whose estimated
-->    cost average (including planning overhead) is more expensive than
-->    the generic plan cost estimate. Once a generic plan is chosen, it
       is used for the remaining lifetime of the prepared statement. Using
       EXECUTE values which are rare in columns with many duplicates can
       generate custom plans that are so much cheaper than the generic
       plan, even after adding planning overhead, that the generic plan
       might never be used.

Also, PG 9.2 is EOL so are you actually using that or something more
recent?  It would be interesting to see if this is true on a supported
version of Postgres.

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

+ As you are, so once was I.  As I am, so you will be. +
+                      Ancient Roman grave inscription +



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

Предыдущее
От: "Naik, Sameer"
Дата:
Сообщение: Generic Plans for Prepared Statement are 158155 times slower thanCustom Plans
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Generic Plans for Prepared Statement are 158155 times slower than Custom Plans