Re: "not related" code blocks for removal of dead rows when using vacuum and this kills the performance

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: "not related" code blocks for removal of dead rows when using vacuum and this kills the performance
Date: 2024-02-19 17:46:19
Message-ID: 6ba1f723a0b6af4a1deedbe543c70ba2630b4e09.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Mon, 2024-02-19 at 16:14 +0000, Lars Aksel Opsahl wrote:
> Then we start testing VACUUM and very simple SQL testing in another window.
>
> We can now show we have performance of "3343.794 ms" and not "0.123 ms", which
> is what we get when we are able to remove dead rows and run a new analyze.
>
> The problem is that as long as the master code is active, we cannot remove
> alle dead rows and that what seems to be killing the performance.
>
> With active I mean in hanging on pg_sleep and remember that this master has
> not created the test table or inserted any data in this test table it self.
>
> Is the expected behavior ?

It is not entirely clear what you are doing, but it seems like you are holding
a database transaction open, and yes, then it is expected behavior that
VACUUM cannot clean up dead rows in the table.

Make sure that your database transactions are short.
Don't use table or row locks to synchronize application threads.
What you could use to synchronize your application threads are advisory locks,
they are not tied to a database transaction.

Yours,
Laurenz Albe

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Lars Aksel Opsahl 2024-02-19 18:36:55 Re: "not related" code blocks for removal of dead rows when using vacuum and this kills the performance
Previous Message Lars Aksel Opsahl 2024-02-19 16:14:25 "not related" code blocks for removal of dead rows when using vacuum and this kills the performance