Skip to content

Commit c28d662

Browse files
committed
Document pg_repack behavior
1 parent 39cc3b4 commit c28d662

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

doc/pg_repack.rst

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -429,13 +429,35 @@ earlier versions which could result in data corruption.
429429
Details
430430
-------
431431

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 repack
433+
^^^^^^^^^^^^^^^^^
435434

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.
435+
To perform a full table repack, pg_repack will:
436+
437+
* create a log table for changes
438+
* create a trigger on the old table to log all changes to the table
439+
* create a new table containing all data in the old table
440+
* create all indexes on the new table
441+
* apply all changes from the log table to the new table
442+
* switch all table files in the system catalog
443+
* drop the old table
444+
445+
pg_repack will only acquire ACCESS EXCLUSIVE locks when creating the trigger and when
446+
switching the table files, all other operations are lock-free on the source table.
447+
448+
449+
Index only repack
450+
^^^^^^^^^^^^^^^^^
451+
452+
To perform a index only repack, pg_repack will:
453+
454+
* create a new index on the table using CONCURRENTLY
455+
* swap the index in the catalog
456+
* drop the old index
457+
458+
Creating indexes concurrently comes with a few caveats, please see `the documentation`__ for details.
459+
460+
.. __: http://www.postgresql.org/docs/current/static/sql-createindex.html#SQL-CREATEINDEX-CONCURRENTLY
439461

440462

441463
Releases

0 commit comments

Comments
 (0)