Re: BUG #17330: EXPLAIN hangs and very long query plans

From: Strahinja Kustudić <strahinjak(at)nordeus(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Peter Geoghegan <pg(at)bowt(dot)ie>, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #17330: EXPLAIN hangs and very long query plans
Date: 2021-12-11 14:40:43
Message-ID: CADKbJJVbqSEv8vL-JCZY7HxPGwX8UQ2rUHs=B0jk0Z9yLtHE4A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Fri, Dec 10, 2021 at 5:39 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> bloat != corruption. The problem you're dealing with here is a whole lot
> of dead index entries at the very end of the index range (could be either
> the lowest or highest entries). The planner is wasting time scanning
> through those to find the extremal non-dead value for a range estimate.
> REINDEX got rid of the dead entries; a VACUUM would have done as well.
>

I completely understand that bloat is different from corruption. It was
just really strange that some mass deletes caused this now because we have
mass deletes regularly on this DB and it has been running for a few years
without any issues. You're right about VACUUM also fixing it, I just tried
it inside Docker and after VACUUM finished it instantly fixed the issue.
The downside is that VACUUM took a long time to finish.

> As noted upthread, more recent PG versions are a bit smarter about
> such cases.
>

As far as I understand there is not much we can do except upgrade to future
major versions, because on this DB we cannot partition data in that way to
be able to drop old partitions.

Thanks again for your help :)

Regards,
Strahinja

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Peter Geoghegan 2021-12-11 22:03:36 Re: BUG #17255: Server crashes in index_delete_sort_cmp() due to race condition with vacuum
Previous Message Andres Freund 2021-12-11 05:48:22 Re: BUG #17321: count(*) on a 1,874,554,883 rows partitioned table takes several minutes.