grayhemp / pgtoolkit

Tools for PostgreSQL maintenance
Other
184 stars 16 forks source link

PgToolkit - tools for PostgreSQL maintenance

Join the chat at https://gitter.im/grayhemp/pgtoolkit

Currently the package contains the only tool pgcompact, we are planning to add much more in the future. Stay tuned.

The list of changes can be found in CHANGES.md. The To-Do List is in TODO.md.

Installation

The easiest way to deploy the toolkit is to download the latest stable version, unpack the archive and copy the autonomous scripts from the fatpack directory to your bin or to just add this directory to your PATH. The autonomous scripts are packed with all the dependencies and need Perl >=5.8.8 to be installed only.

If you need a specific version or branch of the tools, replace the stable with its name string in the URL.

Another way is to git clone the repository

git clone https://github.com/grayhemp/pgtoolkit.git

or to svn checkout it

svn checkout https://github.com/grayhemp/pgtoolkit

Do not forget to switch to the necessary version branch afterwards.

You can also use the autonomous scripts in the fatpack directory or the non-autonomous versions of them in the bin directory. For the latter you need the lib directory either to be in the same sub-directory with bin or to be in your PERL5LIB.

pgcompact

A tool to reduce bloat for tables and indexes without heavy locks and full table rebuilding.

Initially the tool is an automation of the solutions proposed in these publications:

If pgstattuple is installed pgcompact uses it to get a better statistics. It is highly recommended to be for TOASTed tables and indexes.

Usage examples

Shows user manual.

pgcompact --man

Compacts all the bloated tables in all the databases in the cluster plus their bloated indexes. Prints additional progress information.

pgcompact --all --reindex --verbosity info

Compacts all the bloated tables in the billing database and their bloated indexes excepts ones that are in the pgq schema.

pgcompact --dbname billing --exclude-schema pgq --reindex

Features

See Also

License and Copyright

Copyright © 2011-2014 Sergey Konoplev, Maxim Boguk

PgToolkit is released under the PostgreSQL License, read LICENSE.md for additional information.

Authors

Contributors

Thank you: