Re: Allowing REINDEX to have an optional name

From: Bernd Helmle <mailings(at)oopsware(dot)de>
To: Cary Huang <cary(dot)huang(at)highgo(dot)ca>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Cc: Simon Riggs <simon(dot)riggs(at)enterprisedb(dot)com>
Subject: Re: Allowing REINDEX to have an optional name
Date: 2022-05-31 08:51:39
Message-ID: d38bacea8567866d5a96f5b70c083bbe4152854f.camel@oopsware.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Am Freitag, dem 27.05.2022 um 19:08 +0000 schrieb Cary Huang:

[...]

> The patch applies and tests fine and I think this patch has good
> intentions to prevent the default behavior of REINDEX DATABASE to
> cause a deadlock. However, I am not in favor of simply omitting the
> database name after DATABASE clause because of consistency. Almost
> all other queries involving the DATABASE clause require database name
> to be given following after. For example, ALTER DATABASE [dbname]. 
>
> Being able to omit database name for REINDEX DATABASE seems
> inconsistent to me.
>
> The documentation states that REINDEX DATABASE only works on the
> current database, but it still requires the user to provide a
> database name and require that it must match the current database.
> Not very useful option, isn’t it? But it is still required from the
> user to stay consistent with other DATABASE clauses.
>

Hmm, right, but you can see this from another perspective, too: For
example, ALTER DATABASE works by adjusting properties of other
databases very well, SET TABLESPACE can be used when not connected to
the target database only, so you are required to specify its name in
that case.
REINDEX DATABASE cannot reindex other databases than the one we're
connected to. Seen from that point, i currently can't see the logical
justification to have the database name there, besides of "yes, i
really meant that database i am connected to" or consistency.

> Maybe the best way is to keep the query clause as is (with the
> database name still required) and simply don’t let it reindex system
> catalog to prevent deadlock. At the end, give user a notification
> that system catalogs have not been reindexed, and tell them to use
> REINDEX SYSTEM instead.

+1

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2022-05-31 08:52:41 Re: Perform streaming logical transactions by background workers and parallel apply
Previous Message Amit Kapila 2022-05-31 08:37:01 Re: Fix spelling mistake in README file