agora inbox for pgsql-hackers@postgresql.org
help / color / mirror / Atom feedFrom: Antonin Houska <ah@cybertec.at>
To: Robert Treat <rob@xzilla.net>
Cc: jian he <jian.universality@gmail.com>
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Pg Hackers <pgsql-hackers@lists.postgresql.org>
Cc: Mihail Nikalayeu <mihailnikalayeu@gmail.com>
Subject: Re: Adding REPACK [concurrently]
Date: Wed, 05 Nov 2025 08:12:19 +0100
Message-ID: <7224.1762326739@localhost> (raw)
In-Reply-To: <CAJSLCQ0UhdwrF-FBHN6DuPNmTb8mqq-=_jdxjscqoMXjnBkJbw@mail.gmail.com>
References: <202507262156.sb455angijk6@alvherre.pgsql>
<202510301734.pj4uds3mqxx4@alvherre.pgsql>
<CACJufxFPiasoUXFR4SK2QRq6mnztiX=3F82=8PyBrdocX5awBw@mail.gmail.com>
<CAJSLCQ0UhdwrF-FBHN6DuPNmTb8mqq-=_jdxjscqoMXjnBkJbw@mail.gmail.com>
Robert Treat <rob@xzilla.net> wrote:
> On Tue, Nov 4, 2025 at 9:48 PM jian he <jian.universality@gmail.com> wrote:
> > what the expectation of
> > pg_repackdb --index=index_name, the doc is not very helpful.
> >
> > pg_repackdb --analyze --index=zz --verbose
> > pg_repackdb: repacking database "src3"
> > pg_repackdb: error: processing of database "src3" failed: ERROR: "zz"
> > is not an index for table "tenk1"
> >
> > select pg_get_indexdef ('zz'::regclass);
> > pg_get_indexdef
> > ---------------------------------------------------
> > CREATE INDEX zz ON public.tenk2 USING btree (two)
> >
>
> Hmm... yes, this is a bit confusing. I didn't verify it in the code,
> but from memory I think the --index option is meant to be used only in
> conjunction with --table, in which case it would repack the table
> using the specified index. I could be overlooking something though.
The corresponding code is:
+ /*
+ * In REPACK mode, if the 'using_index' option was given but no index
+ * name, filter only tables that have an index with indisclustered set.
+ * (If an index name is given, we trust the user to pass a reasonable list
+ * of tables.)
+ *
+ * XXX it may be worth printing an error if an index name is given with no
+ * list of tables.
+ */
+ if (vacopts->mode == MODE_REPACK &&
+ vacopts->using_index && !vacopts->indexname)
+ {
+ appendPQExpBufferStr(&catalog_query,
+ " AND EXISTS (SELECT 1 FROM pg_catalog.pg_index\n"
+ " WHERE indrelid = c.oid AND indisclustered)\n");
+ }
I'm not sure if it's worth allowing the --index option to have an
argument. Since the user can specify multiple tables, he should also be able
to specify multiple indexes. And then the question would be: what should
happen if the user forgot to specify (or just mistyped) the index name for a
table which does not yet have the clustering index set? Skip that table (and
print out a warning)? Or consider it an error?
--
Antonin Houska
Web: https://www.cybertec-postgresql.com
view thread (416+ messages) latest in thread
Message-ID: <7224.1762326739@localhost>
Permalink: ../7224.1762326739@localhost/
Also on: postgresql.org/message-id/7224.1762326739@localhost
reply
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: ah@cybertec.at, rob@xzilla.net, jian.universality@gmail.com, alvherre@alvh.no-ip.org, pgsql-hackers@lists.postgresql.org, mihailnikalayeu@gmail.com
Subject: Re: Adding REPACK [concurrently]
In-Reply-To: <7224.1762326739@localhost>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox