Re: Use of inefficient index in the presence of dead tuples

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Alexander Staubo <alex(at)purefiction(dot)net>
Cc: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, pgsql-general(at)postgresql(dot)org
Subject: Re: Use of inefficient index in the presence of dead tuples
Date: 2024-05-28 13:43:07
Message-ID: CAKFQuwaphLQO-0jUvuDkS2YwOOgdOPn8Op-8YK0nqC=Lamp-sw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, May 28, 2024, 07:21 Alexander Staubo <alex(at)purefiction(dot)net> wrote:

>
>
> I did explore a solution which is my “plan B” — adding a “done” column,
> then using “UPDATE … SET done = true” rather than deleting the rows. This
> causes dead tuples, of course, but then adding a new index with a “… WHERE
> NOT done” filter fixes the problem by forcing the query to use the right
> index. However, with this solution, rows will still have to be deleted
> *sometime*, so this just delays the problem. But it would allow a “batch
> cleanup”: “DELETE … WHERE done; VACUUM” in one fell swoop.
>

If you incorporate partitions into this, the final removal of the soft
deleted rows becomes and truncate or a drop instead of a delete.

David J.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Kashif Zeeshan 2024-05-28 16:54:22 Re: Pgpool with high availability
Previous Message Alexander Staubo 2024-05-28 13:20:46 Re: Use of inefficient index in the presence of dead tuples