From: Michael Paquier <michael@paquier.xyz>
To: Magnus Hagander <magnus@hagander.net>
Cc: Julien Rouhaud <rjuju123@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: REINDEX backend filtering
Date: Wed, 16 Dec 2020 09:27:53 +0900
Message-ID: <X9lUiVIf747koDXJ@paquier.xyz> (raw)
In-Reply-To: <CABUevEyqGK722MRN5kFemdChfd3gquqcx4M-zGgtHj7n6y1X3A@mail.gmail.com>
References: <20201203093143.GA64934@nol>
<X9cYBC+COBQUfdQ6@paquier.xyz>
<CAOBaU_aPfmc9bJRTeCyiuwKRpQP9J8bj2GW6N3vmof_zvoPb_A@mail.gmail.com>
<CABUevEyqGK722MRN5kFemdChfd3gquqcx4M-zGgtHj7n6y1X3A@mail.gmail.com>
On Tue, Dec 15, 2020 at 06:34:16PM +0100, Magnus Hagander wrote:
> Is this really a common enough operation that we need it in the main grammar?
>
> Having the functionality, definitely, but what if it was "just" a
> function instead? So you'd do something like:
> SELECT 'reindex index ' || i FROM pg_blah(some, arguments, here)
> \gexec
>
> Or even a function that returns the REINDEX commands directly (taking
> a parameter to turn on/off concurrency for example).
>
> That also seems like it would be easier to make flexible, and just as
> easy to plug into reindexdb?
Having control in the grammar to choose which index to reindex for a
table is very useful when it comes to parallel reindexing, because
it is no-brainer in terms of knowing which index to distribute to one
job or another. In short, with this grammar you can just issue a set
of REINDEX TABLE commands that we know will not conflict with each
other. You cannot get that level of control with REINDEX INDEX as it
may be possible that more or more commands conflict if they work on an
index of the same relation because it is required to take lock also on
the parent table. Of course, we could decide to implement a
redistribution logic in all frontend tools that need such things, like
reindexdb, but that's not something I think we should let the client
decide of. A backend-side filtering is IMO much simpler, less code,
and more elegant.
--
Michael
Attachments:
[application/pgp-signature] signature.asc (832B, ../X9lUiVIf747koDXJ@paquier.xyz/2-signature.asc)
download
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: michael@paquier.xyz, magnus@hagander.net, rjuju123@gmail.com, pgsql-hackers@lists.postgresql.org
Subject: Re: REINDEX backend filtering
In-Reply-To: <X9lUiVIf747koDXJ@paquier.xyz>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox