@@ -122,7 +122,9 @@ Options:
122
122
-S, --moveidx move repacked indexes to *TBLSPC * too
123
123
-o, --order-by=COLUMNS order by columns instead of cluster keys
124
124
-n, --no-order do vacuum full instead of cluster
125
- -j, --jobs Use this many parallel jobs for each table
125
+ -j, --jobs=NUM Use this many parallel jobs for each table
126
+ -i, --index=INDEX move only the specified index
127
+ -x, --only-indexes move only indexes of the specified table
126
128
-T, --wait-timeout=SECS timeout to cancel other backends on conflict
127
129
-Z, --no-analyze don't analyze at end
128
130
@@ -149,8 +151,9 @@ Reorg Options
149
151
``pg_repack `` extension is not installed will be skipped.
150
152
151
153
``-t TABLE ``, ``--table=TABLE ``
152
- Reorganize the specified table only. By default, all eligible tables in
153
- the target databases are reorganized.
154
+ Reorganize the specified table(s) only. Multiple tables may be
155
+ reorganized by writing multiple `-t ` switches. By default, all eligible
156
+ tables in the target databases are reorganized.
154
157
155
158
``-o COLUMNS [,...] ``, ``--order-by=COLUMNS [,...] ``
156
159
Perform an online CLUSTER ordered by the specified columns.
@@ -174,6 +177,15 @@ Reorg Options
174
177
Move the indexes too of the repacked tables to the tablespace specified
175
178
by the option ``--tablespace ``.
176
179
180
+ ``-i ``, ``--index ``
181
+ Repack the specified index(es) only. Multiple indexes may be repacked
182
+ by writing multiple `-i ` switches. May be used in conjunction with
183
+ ``--tablespace `` to move the index to a different tablespace.
184
+
185
+ ``-x ``, ``--only-indexes ``
186
+ Repack only the indexes of the specified table(s), which must be specified
187
+ with the ``--table `` option.
188
+
177
189
``-T SECS ``, ``--wait-timeout=SECS ``
178
190
pg_repack needs to take an exclusive lock at the end of the
179
191
reorganization. This setting controls how many seconds pg_repack will
@@ -184,8 +196,8 @@ Reorg Options
184
196
twice this timeout has passed. The default is 60 seconds.
185
197
186
198
``-Z ``, ``--no-analyze ``
187
- Disable ANALYZE after the reorganization. If not specified, run ANALYZE
188
- after the reorganization.
199
+ Disable ANALYZE after a full-table reorganization. If not specified, run
200
+ ANALYZE after the reorganization.
189
201
190
202
191
203
Connection Options
@@ -271,10 +283,18 @@ Perform an online CLUSTER of all the clustered tables in the database
271
283
272
284
$ pg_repack test
273
285
274
- Perform an online VACUUM FULL on the table ``foo `` in the database ``test ``
275
- (an eventual cluster index is ignored)::
286
+ Perform an online VACUUM FULL on the tables ``foo `` and ``bar `` in the
287
+ database ``test `` (an eventual cluster index is ignored)::
288
+
289
+ $ pg_repack --no-order --table foo --table bar test
290
+
291
+ Move all indexes of table ``foo `` to tablespace ``tbs ``::
292
+
293
+ $ pg_repack -d test --table foo --only-indexes --tablespace tbs
294
+
295
+ Move the specified index to tablespace ``tbs ``::
276
296
277
- $ pg_repack --no-order --table foo -d test
297
+ $ pg_repack -d test --index idx --tablespace tbs
278
298
279
299
280
300
Diagnostics
@@ -349,6 +369,22 @@ WARNING: trigger "trg" conflicting on table "tbl"
349
369
350
370
ALTER TRIGGER zzz_my_trigger ON sometable RENAME TO yyy_my_trigger;
351
371
372
+ ERROR: Another pg_repack command may be running on the table. Please try again
373
+ later.
374
+
375
+ There is a chance of deadlock when two concurrent pg_repack commands are run
376
+ on the same table. So, try to run the command after some time.
377
+
378
+ WARNING: Error creating index: ERROR: relation "index_xxxxx" already exists
379
+ DETAIL: An invalid index may have been left behind by a previous pg_repack on
380
+ the table which was interrupted. Please use DROP INDEX "schema"."index_xxxxx"
381
+ to remove this index and try again.
382
+
383
+ A temporary index apparently created by pg_repack has been left behind, and
384
+ we do not want to risk dropping this index ourselves. If the index was in
385
+ fact created by an old pg_repack job which didn't get cleaned up, you
386
+ should just use DROP INDEX and try the repack command again.
387
+
352
388
353
389
Restrictions
354
390
------------
@@ -395,9 +431,13 @@ ALTER TABLE ... SET TABLESPACE
395
431
Details
396
432
-------
397
433
398
- pg_repack creates a work table in the repack schema and sorts the rows in this
399
- table. Then, it updates the system catalogs directly to swap the work table
400
- and the original one.
434
+ To perform full table repacks, pg_repack creates a work table in the "repack"
435
+ schema and sorts the rows in this table. Then, it updates the system catalogs
436
+ directly to swap the work table and the original one.
437
+
438
+ To perform index only repacks, pg_repack creates its work index on the target
439
+ table and then updates the system catalogs directly to swap the work index and
440
+ the original index.
401
441
402
442
403
443
Releases
@@ -413,6 +453,7 @@ Releases
413
453
* Bugfix: correctly handle key indexes with options such as DESC, NULL
414
454
FIRST/LAST, COLLATE (pg_repack issue #3).
415
455
* More helpful program output and error messages.
456
+ * Added feature to repack indexes only.
416
457
417
458
* pg_repack 1.1.8
418
459
0 commit comments