Re: SubtransControlLock and performance problems

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Lars Aksel Opsahl <Lars(dot)Opsahl(at)nibio(dot)no>, "pgsql-performance(at)lists(dot)postgresql(dot)org" <pgsql-performance(at)lists(dot)postgresql(dot)org>
Subject: Re: SubtransControlLock and performance problems
Date: 2020-02-17 16:35:52
Message-ID: 61eeb178848bdc2e0dd6c81ce94f3ace7c1348ff.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Mon, 2020-02-17 at 15:03 +0000, Lars Aksel Opsahl wrote:
> I have tested in branch ( https://github.com/larsop/resolve-overlap-and-gap/tree/add_postgis_topology_using_func)
> where I use only have functions and no procedures and I still have the same problem with subtransaction locks.
>
> Can I based on this assume that the problem is only related to exceptions ?

No, it is related to BEGIN ... EXCEPTION ... END blocks, no matter if
an exception is thrown or not.

As soon as execution enters such a block, a subtransaction is started.

> Does this mean that if have 32 threads running in parallel and I get 2 exceptions in each thread I have reached a state where I will get contention ?

No, it means that if you enter a block with an EXCEPTION clause more
than 64 times in a single transaction, performance will drop.

> Is it any way increase from 64 to a much higher level, when compiling the code ?

Yes, you can increase PGPROC_MAX_CACHED_SUBXIDS in src/include/storage/proc.h

> Basically what I do here is that I catch exceptions when get them and tries to solve the problem in a alternative way.

Either use shorter transactions, or start fewer subtransactions.

Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Pavel Stehule 2020-02-17 18:01:11 Re: SubtransControlLock and performance problems
Previous Message Lars Aksel Opsahl 2020-02-17 15:03:56 Re: SubtransControlLock and performance problems