Re:

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Andrey Klychkov <aaklychkov(at)mail(dot)ru>
Cc: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, pgsql-bugs(at)lists(dot)postgresql(dot)org, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re:
Date: 2020-05-28 06:55:59
Message-ID: 20200528065559.GB3460@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, May 27, 2020 at 03:10:18PM +0300, Andrey Klychkov wrote:
> I got the error related to the one UNIQUE index, why all the new indexes are invalid?
> It would be good:
> * if other indexes are possible to rebuild, reindexdb rebuilds them
> * if not (why?), reindexdb reports why

When you use reindexdb for a database, the tool launches actually a
REINDEX DATABASE that does a reindex for all tables, one-by-one,
launching one transaction for each table reindexed. REINDEX
CONCURRENTLY is a multi-step process consisting in the following:
- Create an index definition which is a copy of the index to rebuild.
- Build the index.
- Validate the index.
- Switch dependencies of the old and new indexes.
- Drop the old index.

And the main point is that when doing a table-level REINDEX, all the
steps above are applied to all the indexes of a relation
one-at-a-time. Hence, if you have N indexes on a table, REINDEX
CONCURRENTLY first creates N new cloned indexes, then it builds N
indexes, it validates N indexes, etc. The reason why you see this
many invalid indexes is that you have a failure at build phase,
meaning that all the other indexes did not reach yet the stage where
they are valid to be used (indisvalid is changed when dependencies are
swapped to be precise), so a failure causes the creation of a set of
invalid indexes, associated with the table previously reindexed.
--
Michael

In response to

  • Re[4]: at 2020-05-27 12:10:18 from Andrey Klychkov

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Paquier 2020-05-28 06:59:48 Re: Re[2]:
Previous Message PG Bug reporting form 2020-05-28 06:39:34 BUG #16468: Doc: release note 13, missing GUC enable_groupingsets_hash_disk