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-11 21:33:25
Message-ID: CAPpHfdsE4O15X=rbNt9f1KAyg2k6XcmHfUOrcWURKQ-yHPggAg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On Mon, Mar 10, 2025 at 1:12 PM Álvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> wrote:
> On 2025-Mar-09, Alexander Korotkov wrote:
>
> > 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?
>
> Oh, this is an egg of Columbus solution, I like it. It seems to work as
> intended on a quick test. Please add some commentary to run_reindex_command.
>
> Maybe another, possibly better way to do this would be to use libpq
> pipeline mode, sending all the commands for a table in one pipeline
> instead of a single command. The advantage of this would be that
> server-side log entries for each command would be separate, and they
> wouldn't appear clumped together in pg_stat_activity and so on.
> However, this would require more invasive changes, so it might be better
> to leave that for a future project -- it's certainly a harder sell for
> such a change to be backpatched. So I'm +1 on your current patch for 17
> and master.

Thank you for your feedback! I also think that pipelining would be a
better options, but it's too invasive for backpatching. I've written
comments for gen_reindex_command() and run_reindex_command(). I'm
going to push this patch to master and 17 if no objections.

------
Regards,
Alexander Korotkov
Supabase

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

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message David Rowley 2025-03-12 02:08:22 Re: pgsql: pg_logicalinspect: Fix possible crash when passing a directory p
Previous Message Heikki Linnakangas 2025-03-11 21:29:21 pgsql: Improve snapmgr.c comment

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2025-03-11 21:42:13 Re: Parallel heap vacuum
Previous Message Masahiko Sawada 2025-03-11 21:21:42 Re: Parallel heap vacuum