forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commita6642b3
committed
Add support for partitioned tables and indexes in REINDEX
Until now, REINDEX was not able to work with partitioned tables andindexes, forcing users to reindex partitions one by one. This extendsREINDEX INDEX and REINDEX TABLE so as they can accept a partitionedindex and table in input, respectively, to reindex all the partitionsassigned to them with physical storage (foreign tables, partitionedtables and indexes are then discarded).This shares some logic with schema and database REINDEX as eachpartition gets processed in its own transaction after building a list ofrelations to work on. This choice has the advantage to minimize thenumber of invalid indexes to one partition with REINDEX CONCURRENTLY inthe event a cancellation or failure in-flight, as the only indexeshandled at once in a single REINDEX CONCURRENTLY loop are the ones fromthe partition being working on.Isolation tests are added to emulate some cases I bumped into whiledeveloping this feature, particularly with the concurrent drop of aleaf partition reindexed. However, this is rather limited as LOCK wouldcause REINDEX to block in the first transaction building the list ofpartitions.Per its multi-transaction nature, this new flavor cannot run in atransaction block, similarly to REINDEX SCHEMA, SYSTEM and DATABASE.Author: Justin Pryzby, Michael PaquierReviewed-by: Anastasia LubennikovaDiscussion:https://postgr.es/m/db12e897-73ff-467e-94cb-4af03705435f.adger.lj@alibaba-inc.com1 parenta547e68 commita6642b3
File tree
13 files changed
+656
-92
lines changed- contrib/postgres_fdw
- expected
- sql
- doc/src/sgml/ref
- src
- backend
- catalog
- commands
- tcop
- include/commands
- test
- isolation
- expected
- specs
- regress
- expected
- sql
- tools/pgindent
13 files changed
+656
-92
lines changedLines changed: 21 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4044 | 4044 |
| |
4045 | 4045 |
| |
4046 | 4046 |
| |
| 4047 | + | |
| 4048 | + | |
| 4049 | + | |
| 4050 | + | |
| 4051 | + | |
| 4052 | + | |
| 4053 | + | |
| 4054 | + | |
| 4055 | + | |
| 4056 | + | |
| 4057 | + | |
| 4058 | + | |
| 4059 | + | |
| 4060 | + | |
| 4061 | + | |
| 4062 | + | |
| 4063 | + | |
| 4064 | + | |
| 4065 | + | |
| 4066 | + | |
| 4067 | + | |
4047 | 4068 |
| |
4048 | 4069 |
| |
4049 | 4070 |
| |
|
Lines changed: 20 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1081 | 1081 |
| |
1082 | 1082 |
| |
1083 | 1083 |
| |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
1084 | 1104 |
| |
1085 | 1105 |
| |
1086 | 1106 |
| |
|
Lines changed: 10 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
88 | 88 |
| |
89 | 89 |
| |
90 | 90 |
| |
91 |
| - | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
92 | 94 |
| |
93 | 95 |
| |
94 | 96 |
| |
| |||
99 | 101 |
| |
100 | 102 |
| |
101 | 103 |
| |
| 104 | + | |
| 105 | + | |
102 | 106 |
| |
103 | 107 |
| |
104 | 108 |
| |
| |||
259 | 263 |
| |
260 | 264 |
| |
261 | 265 |
| |
262 |
| - | |
263 |
| - | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
264 | 271 |
| |
265 | 272 |
| |
266 | 273 |
| |
|
Lines changed: 10 additions & 15 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
77 | 77 |
| |
78 | 78 |
| |
79 | 79 |
| |
| 80 | + | |
80 | 81 |
| |
81 | 82 |
| |
82 | 83 |
| |
| |||
3486 | 3487 |
| |
3487 | 3488 |
| |
3488 | 3489 |
| |
3489 |
| - | |
3490 |
| - | |
| 3490 | + | |
| 3491 | + | |
3491 | 3492 |
| |
3492 | 3493 |
| |
3493 |
| - | |
| 3494 | + | |
| 3495 | + | |
3494 | 3496 |
| |
3495 | 3497 |
| |
3496 | 3498 |
| |
| |||
3707 | 3709 |
| |
3708 | 3710 |
| |
3709 | 3711 |
| |
3710 |
| - | |
3711 |
| - | |
3712 |
| - | |
3713 |
| - | |
| 3712 | + | |
| 3713 | + | |
3714 | 3714 |
| |
3715 | 3715 |
| |
3716 |
| - | |
3717 |
| - | |
3718 |
| - | |
3719 |
| - | |
3720 |
| - | |
3721 |
| - | |
3722 |
| - | |
3723 |
| - | |
| 3716 | + | |
| 3717 | + | |
| 3718 | + | |
3724 | 3719 |
| |
3725 | 3720 |
| |
3726 | 3721 |
| |
|
0 commit comments
Comments
(0)