@@ -429,13 +429,38 @@ earlier versions which could result in data corruption.
429
429
Details
430
430
-------
431
431
432
- To perform full table repacks, pg_repack creates a work table in the "repack"
433
- schema and sorts the rows in this table. Then, it updates the system catalogs
434
- directly to swap the work table and the original one.
432
+ Full Table Repacks
433
+ ^^^^^^^^^^^^^^^^^^
434
+
435
+ To perform a full-table repack, pg_repack will:
436
+
437
+ 1. create a log table to record changes made to the original table
438
+ 2. add a trigger onto the original table, logging INSERTs, UPDATEs and DELETEs into our log table
439
+ 3. create a new table containing all the rows in the old table
440
+ 4. build indexes on this new table
441
+ 5. apply all changes which have accrued in the log table to the new table
442
+ 6. swap the tables, including indexes and toast tables, using the system catalogs
443
+ 7. drop the original table
444
+
445
+ pg_repack will only hold an ACCESS EXCLUSIVE lock for a short period during
446
+ initial setup (steps 1 and 2 above) and during the final swap-and-drop phase
447
+ (steps 6 and 7). For the rest of its time, pg_repack only needs
448
+ to hold an ACCESS SHARE lock on the original table, meaning INSERTs, UPDATEs,
449
+ and DELETEs may proceed as usual.
450
+
451
+
452
+ Index Only Repacks
453
+ ^^^^^^^^^^^^^^^^^^
454
+
455
+ To perform an index-only repack, pg_repack will:
456
+
457
+ 1. create new indexes on the table using CONCURRENTLY matching the definitions of the old indexes
458
+ 2. swap out the old for the new indexes in the catalogs
459
+ 3. drop the old indexes
460
+
461
+ Creating indexes concurrently comes with a few caveats, please see `the documentation `__ for details.
435
462
436
- To perform index only repacks, pg_repack creates its work index on the target
437
- table and then updates the system catalogs directly to swap the work index and
438
- the original index.
463
+ .. __ : http://www.postgresql.org/docs/current/static/sql-createindex.html#SQL-CREATEINDEX-CONCURRENTLY
439
464
440
465
441
466
Releases
0 commit comments