mirror of
https://github.com/postgres/postgres.git
synced 2025-10-22 14:32:25 +03:00
Add support for partitioned tables and indexes in REINDEX
Until now, REINDEX was not able to work with partitioned tables and indexes, forcing users to reindex partitions one by one. This extends REINDEX INDEX and REINDEX TABLE so as they can accept a partitioned index and table in input, respectively, to reindex all the partitions assigned to them with physical storage (foreign tables, partitioned tables and indexes are then discarded). This shares some logic with schema and database REINDEX as each partition gets processed in its own transaction after building a list of relations to work on. This choice has the advantage to minimize the number of invalid indexes to one partition with REINDEX CONCURRENTLY in the event a cancellation or failure in-flight, as the only indexes handled at once in a single REINDEX CONCURRENTLY loop are the ones from the partition being working on. Isolation tests are added to emulate some cases I bumped into while developing this feature, particularly with the concurrent drop of a leaf partition reindexed. However, this is rather limited as LOCK would cause REINDEX to block in the first transaction building the list of partitions. Per its multi-transaction nature, this new flavor cannot run in a transaction block, similarly to REINDEX SCHEMA, SYSTEM and DATABASE. Author: Justin Pryzby, Michael Paquier Reviewed-by: Anastasia Lubennikova Discussion: https://postgr.es/m/db12e897-73ff-467e-94cb-4af03705435f.adger.lj@alibaba-inc.com
This commit is contained in:
@@ -34,8 +34,8 @@ extern ObjectAddress DefineIndex(Oid relationId,
|
||||
bool check_not_in_use,
|
||||
bool skip_build,
|
||||
bool quiet);
|
||||
extern void ReindexIndex(RangeVar *indexRelation, int options);
|
||||
extern Oid ReindexTable(RangeVar *relation, int options);
|
||||
extern void ReindexIndex(RangeVar *indexRelation, int options, bool isTopLevel);
|
||||
extern Oid ReindexTable(RangeVar *relation, int options, bool isTopLevel);
|
||||
extern void ReindexMultipleTables(const char *objectName, ReindexObjectType objectKind,
|
||||
int options);
|
||||
extern char *makeObjectName(const char *name1, const char *name2,
|
||||
|
Reference in New Issue
Block a user