Re: pgsql: reindexdb: Add the index-level REINDEX with multiple jobs

From: Alexander Korotkov <aekorotkov(at)gmail(dot)com>
To: Álvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: Alexander Korotkov <akorotkov(at)postgresql(dot)org>, pgsql-hackers(at)lists(dot)postgresql(dot)org, Maxim Orlov <orlovmg(at)gmail(dot)com>, Svetlana Derevyanko <s(dot)derevyanko(at)postgrespro(dot)ru>
Subject: Re: pgsql: reindexdb: Add the index-level REINDEX with multiple jobs
Date: 2025-03-09 21:53:00
Message-ID: CAPpHfds0Y7pcOrhwuFSJXvs58-=tv=_odWMCoCch01P2QaXq1w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On Sun, Mar 9, 2025 at 4:53 AM Alexander Korotkov <aekorotkov(at)gmail(dot)com> wrote:
> On Sat, Mar 8, 2025 at 12:49 PM Alexander Korotkov <aekorotkov(at)gmail(dot)com> wrote:
> > On Fri, Mar 7, 2025 at 8:20 PM Álvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> wrote:
> > >
> > > On 2024-Mar-25, Alexander Korotkov wrote:
> > >
> > > > reindexdb: Add the index-level REINDEX with multiple jobs
> > > >
> > > > Straight-forward index-level REINDEX is not supported with multiple jobs as
> > > > we cannot control the concurrent processing of multiple indexes depending on
> > > > the same relation. Instead, we dedicate the whole table to certain reindex
> > > > job. Thus, if indexes in the lists belong to different tables, that gives us
> > > > a fair level of parallelism.
> > >
> > > I tested this, because of a refactoring suggestion [1] and I find that
> > > it's rather completely broken.
> >
> > The code was written with assumption that running
> > run_reindex_command() with async == true can schedule a number of
> > queries for a connection. But actually that's not true and everything
> > is broken.
>
> The draft patch for revert is attached. Could you, please, check.

After second thought it's not so hard to fix. The attached patch does
it by putting REINDEX commands related to the same table into a single
SQL statement. Possibly, that could be better than revert given we
need to handle compatibility. What do you think?

------
Regards,
Alexander Korotkov
Supabase

Attachment Content-Type Size
v1-0001-reindexdb-Fix-the-index-level-REINDEX-with-multip.patch application/octet-stream 7.9 KB

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message David Rowley 2025-03-10 00:36:26 pgsql: Fix incorrect #endif comment
Previous Message Heikki Linnakangas 2025-03-09 18:43:39 pgsql: Fix incorrect assertion in libpqwalreceiver

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2025-03-09 22:17:29 Re: Parallel CREATE INDEX for GIN indexes
Previous Message David Rowley 2025-03-09 21:30:48 Re: maintenance_work_mem = 64kB doesn't work for vacuum