Re: Catching errors inside a LOOP is causing performance issues

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: Denisa Cirstescu <Denisa(dot)Cirstescu(at)tangoe(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Catching errors inside a LOOP is causing performance issues
Date: 2017-09-27 17:59:58
Message-ID: 7669.1506535198@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"David G. Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> writes:
> ​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."
> https://www.postgresql.org/docs/current/static/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING

> 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.

Yeah, it's about the overhead of setting up and ending a subtransaction.
That's a fairly expensive mechanism, but we don't have anything cheaper
that is able to recover from arbitrary errors.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jerry Sievers 2017-09-27 18:55:41 Re: WAL Archive command.
Previous Message Igor Polishchuk 2017-09-27 17:59:34 Re: Rsync to a recovering streaming replica?