2012-11-15 12:04:49 +00:00
|
|
|
pg_repack -- Reorganize tables in PostgreSQL databases with minimal locks
|
|
|
|
=========================================================================
|
2012-11-11 01:18:04 +00:00
|
|
|
|
|
|
|
.. contents::
|
|
|
|
:depth: 1
|
|
|
|
:backlinks: none
|
|
|
|
|
2012-11-15 12:04:49 +00:00
|
|
|
pg_repack_ is a PostgreSQL extension which lets you remove bloat from
|
|
|
|
tables and indexes, and optionally restore the physical order of clustered
|
|
|
|
indexes. Unlike CLUSTER_ and `VACUUM FULL`_ it works online, without
|
|
|
|
holding an exclusive lock on the processed tables during processing.
|
|
|
|
pg_repack is efficient to boot, with performance comparable to using
|
|
|
|
CLUSTER directly.
|
2012-11-11 01:18:04 +00:00
|
|
|
|
2012-11-13 14:33:08 +00:00
|
|
|
pg_repack is a fork of the previous pg_reorg_ project. Please check the
|
|
|
|
`project page`_ for bug report and development information.
|
2012-11-11 01:18:04 +00:00
|
|
|
|
|
|
|
You can choose one of the following methods to reorganize:
|
|
|
|
|
|
|
|
* Online CLUSTER (ordered by cluster index)
|
|
|
|
* Ordered by specified columns
|
|
|
|
* Online VACUUM FULL (packing rows only)
|
2013-07-05 21:02:28 -04:00
|
|
|
* Rebuild or relocate only the indexes of a table
|
2012-11-11 01:18:04 +00:00
|
|
|
|
|
|
|
NOTICE:
|
|
|
|
|
|
|
|
* Only superusers can use the utility.
|
2012-11-13 14:07:43 +00:00
|
|
|
* Target table must have a PRIMARY KEY, or at least a UNIQUE total index on a
|
|
|
|
NOT NULL column.
|
2012-11-11 01:18:04 +00:00
|
|
|
|
2012-11-11 02:38:09 +00:00
|
|
|
.. _pg_repack: http://reorg.github.com/pg_repack
|
2012-11-15 12:04:49 +00:00
|
|
|
.. _CLUSTER: http://www.postgresql.org/docs/current/static/sql-cluster.html
|
|
|
|
.. _VACUUM FULL: VACUUM_
|
|
|
|
.. _VACUUM: http://www.postgresql.org/docs/current/static/sql-vacuum.html
|
2012-11-11 02:38:09 +00:00
|
|
|
.. _project page: https://github.com/reorg/pg_repack
|
2012-11-11 01:18:04 +00:00
|
|
|
.. _pg_reorg: http://reorg.projects.pgfoundry.org/
|
|
|
|
|
|
|
|
|
2012-11-13 14:33:08 +00:00
|
|
|
Requirements
|
|
|
|
------------
|
2012-11-11 01:18:04 +00:00
|
|
|
|
2012-11-13 14:33:08 +00:00
|
|
|
PostgreSQL versions
|
2013-07-05 21:02:28 -04:00
|
|
|
PostgreSQL 8.3, 8.4, 9.0, 9.1, 9.2, 9.3
|
2012-11-11 01:18:04 +00:00
|
|
|
|
2012-11-13 14:33:08 +00:00
|
|
|
Disks
|
2013-07-05 21:02:28 -04:00
|
|
|
Performing a full-table repack requires free disk space about twice as
|
|
|
|
large as the target table(s) and its indexes. For example, if the total
|
|
|
|
size of the tables and indexes to be reorganized is 1GB, an additional 2GB
|
|
|
|
of disk space is required.
|
2012-11-11 01:18:04 +00:00
|
|
|
|
|
|
|
|
2012-11-15 15:36:44 +00:00
|
|
|
Download
|
|
|
|
--------
|
|
|
|
|
|
|
|
You can `download pg_repack`__ from the PGXN website. Unpack the archive and
|
|
|
|
follow the installation_ instructions.
|
|
|
|
|
|
|
|
.. __: http://pgxn.org/dist/pg_repack/
|
|
|
|
|
|
|
|
Alternatively you can use the `PGXN Client`_ to download, compile and install
|
|
|
|
the package; use::
|
|
|
|
|
|
|
|
$ pgxn install pg_repack
|
|
|
|
|
|
|
|
Check the `pgxn install documentation`__ for the options available.
|
|
|
|
|
|
|
|
.. _PGXN Client: http://pgxnclient.projects.pgfoundry.org/
|
|
|
|
.. __: http://pgxnclient.projects.pgfoundry.org/usage.html#pgxn-install
|
|
|
|
|
|
|
|
|
2012-11-13 14:33:08 +00:00
|
|
|
Installation
|
|
|
|
------------
|
|
|
|
|
|
|
|
pg_repack can be built with ``make`` on UNIX or Linux. The PGXS build
|
|
|
|
framework is used automatically. Before building, you might need to install
|
|
|
|
the PostgreSQL development packages (``postgresql-devel``, etc.) and add the
|
|
|
|
directory containing ``pg_config`` to your ``$PATH``. Then you can run::
|
2012-11-11 01:18:04 +00:00
|
|
|
|
2012-11-13 14:33:08 +00:00
|
|
|
$ cd pg_repack
|
|
|
|
$ make
|
|
|
|
$ sudo make install
|
|
|
|
|
|
|
|
You can also use Microsoft Visual C++ 2010 to build the program on Windows.
|
|
|
|
There are project files in the ``msvc`` folder.
|
|
|
|
|
|
|
|
After installation, load the pg_repack extension in the database you want to
|
|
|
|
process. On PostgreSQL 9.1 and following pg_repack is packaged as an
|
|
|
|
extension, so you can execute::
|
|
|
|
|
|
|
|
$ psql -c "CREATE EXTENSION pg_repack" -d your_database
|
|
|
|
|
|
|
|
For previous PostgreSQL versions you should load the script
|
|
|
|
``$SHAREDIR/contrib/pg_repack.sql`` in the database to process; you can
|
|
|
|
get ``$SHAREDIR`` using ``pg_config --sharedir``, e.g. ::
|
|
|
|
|
|
|
|
$ psql -f "$(pg_config --sharedir)/contrib/pg_repack.sql" -d your_database
|
|
|
|
|
|
|
|
You can remove pg_repack from a PostgreSQL 9.1 and following database using
|
|
|
|
``DROP EXTENSION pg_repack``. For previous Postgresql versions load the
|
|
|
|
``$SHAREDIR/contrib/uninstall_pg_repack.sql`` script or just drop the
|
|
|
|
``repack`` schema.
|
|
|
|
|
|
|
|
If you are upgrading from a previous version of pg_repack or pg_reorg, just
|
|
|
|
drop the old version from the database as explained above and install the new
|
|
|
|
version.
|
|
|
|
|
|
|
|
|
|
|
|
Usage
|
|
|
|
-----
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
pg_repack [OPTION]... [DBNAME]
|
|
|
|
|
|
|
|
The following options can be specified in ``OPTIONS``.
|
|
|
|
|
|
|
|
Options:
|
|
|
|
-a, --all repack all databases
|
|
|
|
-t, --table=TABLE repack specific table only
|
2014-05-24 15:42:24 -04:00
|
|
|
-c, --schema=SCHEMA repack tables in specific schema only
|
2013-04-17 09:17:35 +01:00
|
|
|
-s, --tablespace=TBLSPC move repacked tables to a new tablespace
|
2013-04-18 02:49:56 +01:00
|
|
|
-S, --moveidx move repacked indexes to *TBLSPC* too
|
2013-04-17 01:44:50 +01:00
|
|
|
-o, --order-by=COLUMNS order by columns instead of cluster keys
|
|
|
|
-n, --no-order do vacuum full instead of cluster
|
2014-01-26 10:28:29 +00:00
|
|
|
-N, --dry-run print what would have been repacked and exit
|
2013-06-29 10:13:05 -04:00
|
|
|
-j, --jobs=NUM Use this many parallel jobs for each table
|
|
|
|
-i, --index=INDEX move only the specified index
|
|
|
|
-x, --only-indexes move only indexes of the specified table
|
2012-11-13 14:33:08 +00:00
|
|
|
-T, --wait-timeout=SECS timeout to cancel other backends on conflict
|
|
|
|
-Z, --no-analyze don't analyze at end
|
|
|
|
|
|
|
|
Connection options:
|
|
|
|
-d, --dbname=DBNAME database to connect
|
|
|
|
-h, --host=HOSTNAME database server host or socket directory
|
|
|
|
-p, --port=PORT database server port
|
|
|
|
-U, --username=USERNAME user name to connect as
|
|
|
|
-w, --no-password never prompt for password
|
|
|
|
-W, --password force password prompt
|
|
|
|
|
|
|
|
Generic options:
|
|
|
|
-e, --echo echo queries
|
|
|
|
-E, --elevel=LEVEL set output message level
|
|
|
|
--help show this help, then exit
|
|
|
|
--version output version information, then exit
|
2012-11-11 01:18:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
Reorg Options
|
|
|
|
^^^^^^^^^^^^^
|
|
|
|
|
2013-04-17 01:44:50 +01:00
|
|
|
``-a``, ``--all``
|
2013-07-05 21:02:28 -04:00
|
|
|
Attempt to repack all the databases of the cluster. Databases where the
|
2013-04-17 01:44:50 +01:00
|
|
|
``pg_repack`` extension is not installed will be skipped.
|
2012-12-13 21:10:59 -07:00
|
|
|
|
2013-04-17 01:44:50 +01:00
|
|
|
``-t TABLE``, ``--table=TABLE``
|
2013-06-29 10:13:05 -04:00
|
|
|
Reorganize the specified table(s) only. Multiple tables may be
|
2013-11-05 01:39:07 +00:00
|
|
|
reorganized by writing multiple ``-t`` switches. By default, all eligible
|
2013-06-29 10:13:05 -04:00
|
|
|
tables in the target databases are reorganized.
|
2012-11-11 01:18:04 +00:00
|
|
|
|
2014-01-24 15:14:16 +01:00
|
|
|
``-c``, ``--schema``
|
2014-05-24 15:42:24 -04:00
|
|
|
Repack the tables in the specified schema(s) only. Multiple schemas may
|
|
|
|
be repacked by writing multiple ``-c`` switches. May be used in
|
|
|
|
conjunction with ``--tablespace`` to move tables to a different tablespace.
|
2014-01-24 15:14:16 +01:00
|
|
|
|
2012-11-11 01:18:04 +00:00
|
|
|
``-o COLUMNS [,...]``, ``--order-by=COLUMNS [,...]``
|
2012-11-19 11:13:33 +00:00
|
|
|
Perform an online CLUSTER ordered by the specified columns.
|
2012-11-11 01:18:04 +00:00
|
|
|
|
2013-04-17 01:44:50 +01:00
|
|
|
``-n``, ``--no-order``
|
|
|
|
Perform an online VACUUM FULL. Since version 1.2 this is the default for
|
|
|
|
non-clustered tables.
|
|
|
|
|
2014-01-24 15:15:35 +01:00
|
|
|
``-N``, ``--dry-run``
|
|
|
|
List what would be repacked and exit.
|
|
|
|
|
2013-04-17 01:44:50 +01:00
|
|
|
``-j``, ``--jobs``
|
|
|
|
Create the specified number of extra connections to PostgreSQL, and
|
|
|
|
use these extra connections to parallelize the rebuild of indexes
|
2013-07-05 21:02:28 -04:00
|
|
|
on each table. Parallel index builds are only supported for full-table
|
|
|
|
repacks, not with ``--index`` or ``--only-indexes`` options. If your
|
|
|
|
PostgreSQL server has extra cores and disk I/O available, this can be a
|
|
|
|
useful way to speed up pg_repack.
|
2012-11-11 01:18:04 +00:00
|
|
|
|
2013-04-17 09:17:35 +01:00
|
|
|
``-s TBLSPC``, ``--tablespace=TBLSPC``
|
2013-04-16 23:39:51 +01:00
|
|
|
Move the repacked tables to the specified tablespace: essentially an
|
2013-07-05 21:02:28 -04:00
|
|
|
online version of ``ALTER TABLE ... SET TABLESPACE``. The tables' indexes
|
|
|
|
are left in the original tablespace unless ``--moveidx`` is specified too.
|
2013-04-16 23:39:51 +01:00
|
|
|
|
|
|
|
``-S``, ``--moveidx``
|
2013-07-05 21:02:28 -04:00
|
|
|
Also move the indexes of the repacked tables to the tablespace specified
|
|
|
|
by the ``--tablespace`` option.
|
2013-04-16 23:39:51 +01:00
|
|
|
|
2013-06-29 10:13:05 -04:00
|
|
|
``-i``, ``--index``
|
|
|
|
Repack the specified index(es) only. Multiple indexes may be repacked
|
2013-11-05 01:39:07 +00:00
|
|
|
by writing multiple ``-i`` switches. May be used in conjunction with
|
2013-06-29 10:13:05 -04:00
|
|
|
``--tablespace`` to move the index to a different tablespace.
|
|
|
|
|
|
|
|
``-x``, ``--only-indexes``
|
|
|
|
Repack only the indexes of the specified table(s), which must be specified
|
|
|
|
with the ``--table`` option.
|
|
|
|
|
2012-11-11 01:18:04 +00:00
|
|
|
``-T SECS``, ``--wait-timeout=SECS``
|
|
|
|
pg_repack needs to take an exclusive lock at the end of the
|
2012-11-19 11:13:33 +00:00
|
|
|
reorganization. This setting controls how many seconds pg_repack will
|
2012-11-19 07:42:21 -07:00
|
|
|
wait to acquire this lock. If the lock cannot be taken after this duration,
|
2012-11-19 11:13:33 +00:00
|
|
|
pg_repack will forcibly cancel the conflicting queries. If you are using
|
|
|
|
PostgreSQL version 8.4 or newer, pg_repack will fall back to using
|
|
|
|
pg_terminate_backend() to disconnect any remaining backends after
|
|
|
|
twice this timeout has passed. The default is 60 seconds.
|
2012-11-11 01:18:04 +00:00
|
|
|
|
|
|
|
``-Z``, ``--no-analyze``
|
2013-06-29 10:13:05 -04:00
|
|
|
Disable ANALYZE after a full-table reorganization. If not specified, run
|
|
|
|
ANALYZE after the reorganization.
|
2012-11-11 01:18:04 +00:00
|
|
|
|
2013-04-17 01:44:50 +01:00
|
|
|
|
2012-11-11 01:18:04 +00:00
|
|
|
Connection Options
|
|
|
|
^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
Options to connect to servers. You cannot use ``--all`` and ``--dbname`` or
|
|
|
|
``--table`` together.
|
|
|
|
|
|
|
|
``-a``, ``--all``
|
|
|
|
Reorganize all databases.
|
|
|
|
|
|
|
|
``-d DBNAME``, ``--dbname=DBNAME``
|
|
|
|
Specifies the name of the database to be reorganized. If this is not
|
|
|
|
specified and ``-a`` (or ``--all``) is not used, the database name is read
|
|
|
|
from the environment variable PGDATABASE. If that is not set, the user
|
|
|
|
name specified for the connection is used.
|
|
|
|
|
|
|
|
``-h HOSTNAME``, ``--host=HOSTNAME``
|
|
|
|
Specifies the host name of the machine on which the server is running. If
|
|
|
|
the value begins with a slash, it is used as the directory for the Unix
|
|
|
|
domain socket.
|
|
|
|
|
|
|
|
``-p PORT``, ``--port=PORT``
|
|
|
|
Specifies the TCP port or local Unix domain socket file extension on which
|
|
|
|
the server is listening for connections.
|
|
|
|
|
|
|
|
``-U USERNAME``, ``--username=USERNAME``
|
|
|
|
User name to connect as.
|
|
|
|
|
|
|
|
``-w``, ``--no-password``
|
|
|
|
Never issue a password prompt. If the server requires password
|
|
|
|
authentication and a password is not available by other means such as a
|
2012-11-15 00:58:58 +00:00
|
|
|
``.pgpass`` file, the connection attempt will fail. This option can be
|
|
|
|
useful in batch jobs and scripts where no user is present to enter a
|
|
|
|
password.
|
2012-11-11 01:18:04 +00:00
|
|
|
|
|
|
|
``-W``, ``--password``
|
|
|
|
Force the program to prompt for a password before connecting to a
|
|
|
|
database.
|
|
|
|
|
|
|
|
This option is never essential, since the program will automatically
|
|
|
|
prompt for a password if the server demands password authentication.
|
|
|
|
However, pg_repack will waste a connection attempt finding out that the
|
|
|
|
server wants a password. In some cases it is worth typing ``-W`` to avoid
|
|
|
|
the extra connection attempt.
|
|
|
|
|
|
|
|
|
|
|
|
Generic Options
|
|
|
|
^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
``-e``, ``--echo``
|
|
|
|
Echo commands sent to server.
|
|
|
|
|
|
|
|
``-E LEVEL``, ``--elevel=LEVEL``
|
|
|
|
Choose the output message level from ``DEBUG``, ``INFO``, ``NOTICE``,
|
|
|
|
``WARNING``, ``ERROR``, ``LOG``, ``FATAL``, and ``PANIC``. The default is
|
|
|
|
``INFO``.
|
|
|
|
|
|
|
|
``--help``
|
|
|
|
Show usage of the program.
|
|
|
|
|
|
|
|
``--version``
|
|
|
|
Show the version number of the program.
|
|
|
|
|
|
|
|
|
|
|
|
Environment
|
|
|
|
-----------
|
|
|
|
|
|
|
|
``PGDATABASE``, ``PGHOST``, ``PGPORT``, ``PGUSER``
|
|
|
|
Default connection parameters
|
|
|
|
|
|
|
|
This utility, like most other PostgreSQL utilities, also uses the
|
|
|
|
environment variables supported by libpq (see `Environment Variables`__).
|
|
|
|
|
|
|
|
.. __: http://www.postgresql.org/docs/current/static/libpq-envars.html
|
|
|
|
|
|
|
|
|
2012-11-13 14:33:08 +00:00
|
|
|
Examples
|
|
|
|
--------
|
|
|
|
|
2013-04-17 01:42:22 +01:00
|
|
|
Perform an online CLUSTER of all the clustered tables in the database
|
|
|
|
``test``, and perform an online VACUUM FULL of all the non-clustered tables::
|
2012-11-13 14:33:08 +00:00
|
|
|
|
|
|
|
$ pg_repack test
|
|
|
|
|
2013-06-29 10:13:05 -04:00
|
|
|
Perform an online VACUUM FULL on the tables ``foo`` and ``bar`` in the
|
|
|
|
database ``test`` (an eventual cluster index is ignored)::
|
|
|
|
|
|
|
|
$ pg_repack --no-order --table foo --table bar test
|
|
|
|
|
|
|
|
Move all indexes of table ``foo`` to tablespace ``tbs``::
|
|
|
|
|
|
|
|
$ pg_repack -d test --table foo --only-indexes --tablespace tbs
|
|
|
|
|
|
|
|
Move the specified index to tablespace ``tbs``::
|
2012-11-13 14:33:08 +00:00
|
|
|
|
2013-06-29 10:13:05 -04:00
|
|
|
$ pg_repack -d test --index idx --tablespace tbs
|
2012-11-13 14:33:08 +00:00
|
|
|
|
|
|
|
|
2012-11-11 01:18:04 +00:00
|
|
|
Diagnostics
|
|
|
|
-----------
|
|
|
|
|
|
|
|
Error messages are reported when pg_repack fails. The following list shows the
|
|
|
|
cause of errors.
|
|
|
|
|
2012-11-13 14:07:43 +00:00
|
|
|
You need to cleanup by hand after fatal errors. To cleanup, just remove
|
|
|
|
pg_repack from the database and install it again: for PostgreSQL 9.1 and
|
|
|
|
following execute ``DROP EXTENSION pg_repack CASCADE`` in the database where
|
|
|
|
the error occurred, followed by ``CREATE EXTENSION pg_repack``; for previous
|
|
|
|
version load the script ``$SHAREDIR/contrib/uninstall_pg_repack.sql`` into the
|
|
|
|
database where the error occured and then load
|
|
|
|
``$SHAREDIR/contrib/pg_repack.sql`` again.
|
2012-11-11 01:18:04 +00:00
|
|
|
|
2012-11-22 23:23:30 +00:00
|
|
|
.. class:: diag
|
|
|
|
|
2013-04-18 02:49:56 +01:00
|
|
|
INFO: database "db" skipped: pg_repack VER is not installed in the database
|
|
|
|
pg_repack is not installed in the database when the ``--all`` option is
|
2012-11-11 01:18:04 +00:00
|
|
|
specified.
|
|
|
|
|
2012-11-19 11:13:33 +00:00
|
|
|
Create the pg_repack extension in the database.
|
2012-11-11 01:18:04 +00:00
|
|
|
|
2013-04-18 02:49:56 +01:00
|
|
|
ERROR: pg_repack VER is not installed in the database
|
2012-11-11 01:18:04 +00:00
|
|
|
pg_repack is not installed in the database specified by ``--dbname``.
|
|
|
|
|
2012-11-19 11:13:33 +00:00
|
|
|
Create the pg_repack extension in the database.
|
2012-11-11 01:18:04 +00:00
|
|
|
|
2012-10-18 00:43:45 +01:00
|
|
|
ERROR: program 'pg_repack V1' does not match database library 'pg_repack V2'
|
|
|
|
There is a mismatch between the ``pg_repack`` binary and the database
|
|
|
|
library (``.so`` or ``.dll``).
|
|
|
|
|
|
|
|
The mismatch could be due to the wrong binary in the ``$PATH`` or the
|
|
|
|
wrong database being addressed. Check the program directory and the
|
|
|
|
database; if they are what expected you may need to repeat pg_repack
|
|
|
|
installation.
|
|
|
|
|
2012-11-15 23:37:09 +00:00
|
|
|
ERROR: extension 'pg_repack V1' required, found extension 'pg_repack V2'
|
|
|
|
The SQL extension found in the database does not match the version
|
|
|
|
required by the pg_repack program.
|
|
|
|
|
|
|
|
You should drop the extension from the database and reload it as described
|
|
|
|
in the installation_ section.
|
|
|
|
|
2012-11-19 11:13:33 +00:00
|
|
|
ERROR: relation "table" must have a primary key or not-null unique keys
|
|
|
|
The target table doesn't have a PRIMARY KEY or any UNIQUE constraints
|
|
|
|
defined.
|
2012-11-11 01:18:04 +00:00
|
|
|
|
2012-11-19 11:13:33 +00:00
|
|
|
Define a PRIMARY KEY or a UNIQUE constraint on the table.
|
2012-11-11 01:18:04 +00:00
|
|
|
|
2013-04-17 01:42:22 +01:00
|
|
|
ERROR: query failed: ERROR: column "col" does not exist
|
2012-11-11 01:18:04 +00:00
|
|
|
The target table doesn't have columns specified by ``--order-by`` option.
|
|
|
|
|
|
|
|
Specify existing columns.
|
|
|
|
|
2013-07-05 21:02:28 -04:00
|
|
|
WARNING: the table "tbl" already has a trigger called z_repack_trigger
|
2013-04-17 00:53:54 +01:00
|
|
|
The trigger was probably installed during a previous attempt to run
|
|
|
|
pg_repack on the table which was interrupted and for some reason failed
|
|
|
|
to clean up the temporary objects.
|
2012-11-11 01:18:04 +00:00
|
|
|
|
2012-12-01 12:19:48 +00:00
|
|
|
You can remove all the temporary objects by dropping and re-creating the
|
|
|
|
extension: see the installation_ section for the details.
|
2012-11-11 01:18:04 +00:00
|
|
|
|
2013-04-17 00:53:54 +01:00
|
|
|
WARNING: trigger "trg" conflicting on table "tbl"
|
2012-12-01 12:19:48 +00:00
|
|
|
The target table has a trigger whose name follows ``z_repack_trigger``
|
|
|
|
in alphabetical order.
|
2012-11-11 01:18:04 +00:00
|
|
|
|
2012-12-01 12:19:48 +00:00
|
|
|
The ``z_repack_trigger`` should be the last BEFORE trigger to fire.
|
2013-07-05 21:02:28 -04:00
|
|
|
Please rename your trigger so that it sorts alphabetically before
|
2013-04-17 00:53:54 +01:00
|
|
|
pg_repack's one; you can use::
|
|
|
|
|
|
|
|
ALTER TRIGGER zzz_my_trigger ON sometable RENAME TO yyy_my_trigger;
|
2012-11-11 01:18:04 +00:00
|
|
|
|
2013-06-29 10:13:05 -04:00
|
|
|
ERROR: Another pg_repack command may be running on the table. Please try again
|
|
|
|
later.
|
|
|
|
|
|
|
|
There is a chance of deadlock when two concurrent pg_repack commands are run
|
|
|
|
on the same table. So, try to run the command after some time.
|
|
|
|
|
2013-07-05 21:02:28 -04:00
|
|
|
WARNING: Cannot create index "schema"."index_xxxxx", already exists
|
2013-06-29 10:13:05 -04:00
|
|
|
DETAIL: An invalid index may have been left behind by a previous pg_repack on
|
|
|
|
the table which was interrupted. Please use DROP INDEX "schema"."index_xxxxx"
|
|
|
|
to remove this index and try again.
|
|
|
|
|
|
|
|
A temporary index apparently created by pg_repack has been left behind, and
|
|
|
|
we do not want to risk dropping this index ourselves. If the index was in
|
2013-11-05 01:39:07 +00:00
|
|
|
fact created by an old pg_repack job which didn't get cleaned up, you
|
|
|
|
should just use DROP INDEX and try the repack command again.
|
2013-06-29 10:13:05 -04:00
|
|
|
|
2012-11-11 01:18:04 +00:00
|
|
|
|
|
|
|
Restrictions
|
|
|
|
------------
|
|
|
|
|
2013-07-05 21:02:28 -04:00
|
|
|
pg_repack comes with the following restrictions.
|
2012-11-11 01:18:04 +00:00
|
|
|
|
|
|
|
Temp tables
|
|
|
|
^^^^^^^^^^^
|
|
|
|
|
|
|
|
pg_repack cannot reorganize temp tables.
|
|
|
|
|
|
|
|
GiST indexes
|
|
|
|
^^^^^^^^^^^^
|
|
|
|
|
|
|
|
pg_repack cannot reorganize tables using GiST indexes.
|
|
|
|
|
|
|
|
DDL commands
|
|
|
|
^^^^^^^^^^^^
|
|
|
|
|
2013-07-05 21:02:28 -04:00
|
|
|
You will not be able to perform DDL commands of the target table(s) **except**
|
|
|
|
VACUUM or ANALYZE while pg_repack is working. pg_repack will hold an
|
|
|
|
ACCESS SHARE lock on the target table during a full-table repack, to enforce
|
|
|
|
this restriction.
|
2012-11-11 01:18:04 +00:00
|
|
|
|
2013-07-05 21:02:28 -04:00
|
|
|
If you are using version 1.1.8 or earlier, you must not attempt to perform any
|
|
|
|
DDL commands on the target table(s) while pg_repack is running. In many cases
|
|
|
|
pg_repack would fail and rollback correctly, but there were some cases in these
|
|
|
|
earlier versions which could result in data corruption.
|
2012-11-11 01:18:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
Details
|
|
|
|
-------
|
|
|
|
|
2013-06-29 10:13:05 -04:00
|
|
|
To perform full table repacks, pg_repack creates a work table in the "repack"
|
|
|
|
schema and sorts the rows in this table. Then, it updates the system catalogs
|
|
|
|
directly to swap the work table and the original one.
|
|
|
|
|
|
|
|
To perform index only repacks, pg_repack creates its work index on the target
|
|
|
|
table and then updates the system catalogs directly to swap the work index and
|
|
|
|
the original index.
|
2012-11-11 01:18:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
Releases
|
|
|
|
--------
|
|
|
|
|
2014-01-26 10:28:29 +00:00
|
|
|
* pg_repack 1.3
|
|
|
|
|
|
|
|
* Added ``--dry-run`` to do a dry run.
|
2014-05-24 15:42:24 -04:00
|
|
|
* Added ``--schema`` to repack only the specified schema.
|
2014-01-26 10:28:29 +00:00
|
|
|
|
2013-04-16 23:50:52 +01:00
|
|
|
* pg_repack 1.2
|
|
|
|
|
2014-05-24 00:27:05 -04:00
|
|
|
* Support PostgreSQL 9.3.
|
2013-04-18 02:49:56 +01:00
|
|
|
* Added ``--tablespace`` and ``--moveidx`` options to perform online
|
|
|
|
SET TABLESPACE.
|
2014-05-24 00:27:05 -04:00
|
|
|
* Added ``--index`` to repack the specified index only.
|
|
|
|
* Added ``--only-indexes`` to repack only the indexes of the specified table
|
2013-04-18 02:49:56 +01:00
|
|
|
* Added ``--jobs`` option for parallel operation.
|
|
|
|
* Don't require ``--no-order`` to perform a VACUUM FULL on non-clustered
|
|
|
|
tables (pg_repack issue #6).
|
2013-11-05 01:39:07 +00:00
|
|
|
* Don't wait for locks held in other databases (pg_repack issue #11).
|
2013-04-16 23:50:52 +01:00
|
|
|
* Bugfix: correctly handle key indexes with options such as DESC, NULL
|
|
|
|
FIRST/LAST, COLLATE (pg_repack issue #3).
|
2014-05-19 10:41:44 +01:00
|
|
|
* Fixed data corruption bug on delete (pg_repack issue #23).
|
2013-04-18 02:49:56 +01:00
|
|
|
* More helpful program output and error messages.
|
2013-04-16 23:50:52 +01:00
|
|
|
|
2012-11-11 01:18:04 +00:00
|
|
|
* pg_repack 1.1.8
|
|
|
|
|
|
|
|
* Added support for PostgreSQL 9.2.
|
|
|
|
* Added support for CREATE EXTENSION on PostgreSQL 9.1 and following.
|
|
|
|
* Give user feedback while waiting for transactions to finish (pg_reorg
|
|
|
|
issue #5).
|
|
|
|
* Bugfix: Allow running on newly promoted streaming replication slaves
|
|
|
|
(pg_reorg issue #1).
|
2012-11-16 22:28:52 +00:00
|
|
|
* Bugfix: Fix interaction between pg_repack and Slony 2.0/2.1 (pg_reorg
|
|
|
|
issue #4)
|
2012-11-11 01:18:04 +00:00
|
|
|
* Bugfix: Properly escape column names (pg_reorg issue #6).
|
|
|
|
* Bugfix: Avoid recreating invalid indexes, or choosing them as key
|
|
|
|
(pg_reorg issue #9).
|
2012-11-15 00:19:29 +00:00
|
|
|
* Bugfix: Never choose a partial index as primary key (pg_reorg issue #22).
|
2012-11-11 01:18:04 +00:00
|
|
|
|
|
|
|
* pg_reorg 1.1.7 (2011-08-07)
|
|
|
|
|
|
|
|
* Bugfix: VIEWs and FUNCTIONs could be corrupted that used a reorganized
|
|
|
|
table which has a dropped column.
|
|
|
|
* Supports PostgreSQL 9.1 and 9.2dev. (but EXTENSION is not yet)
|
|
|
|
|
|
|
|
|
|
|
|
See Also
|
|
|
|
--------
|
|
|
|
|
2012-11-11 02:38:09 +00:00
|
|
|
* `clusterdb <http://www.postgresql.org/docs/current/static/app-clusterdb.html>`__
|
|
|
|
* `vacuumdb <http://www.postgresql.org/docs/current/static/app-vacuumdb.html>`__
|
2012-11-11 01:18:04 +00:00
|
|
|
|