Re: [GENERAL] Catching errors inside a LOOP is causing performance issues

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: [GENERAL] Catching errors inside a LOOP is causing performance issues
Дата
Msg-id CAKFQuwZ_88me2heiJ6=5S1oyNDK0OcVvJO=xM1y20Oy9WKhJtA@mail.gmail.com
обсуждение исходный текст
Ответ на [GENERAL] Catching errors inside a LOOP is causing performance issues  (Denisa Cirstescu <Denisa.Cirstescu@tangoe.com>)
Ответы Re: [GENERAL] Catching errors inside a LOOP is causing performance issues  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
On Mon, Sep 25, 2017 at 9:13 AM, Denisa Cirstescu <Denisa.Cirstescu@tangoe.com> wrote:


Can someone please explain to me why this worked?

What happened behind the scenes?

I suspect that when you catch exceptions inside of a LOOP and the code ends up generating an exception, Postgres can’t use cached plans to optimize that code so it ends up planning the code at each iteration and this causes performance issues.

Is my assumption correct?



​Not sure how much detail you are looking for but the docs say this:

"​Tip: A block containing an EXCEPTION clause is significantly more expensive to enter and exit than a block without one. Therefore, don't use EXCEPTION without need."


I'm somewhat doubting "plan caching" has anything to do with this; I suspect its basically that there is high memory and runtime overhead to deal with the possibilities of needing to convert a exception into a branch instead of allowing it to be fatal.

David J.

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

Предыдущее
От: George Neuner
Дата:
Сообщение: Re: [GENERAL] Speed of conversion from int to bigint
Следующее
От: Igor Polishchuk
Дата:
Сообщение: [GENERAL] Rsync to a recovering streaming replica?