Managing PostgreSQL Extensions
Quick Start
Pigsty provides 600 extensions. To use an extension, complete four steps: download, install, configure, and enable.
For complete extension reference, see Extensions. For available extensions, see Extension Catalog.
| Action | Command | Description |
|---|---|---|
| Download Extensions | ./infra.yml -t repo_build | Download extensions to local repo |
| Install Extensions | bin/pgsql-ext <cls> | Install extension packages on cluster |
| Configure Extensions | pg edit-config <cls> -p | Add to preload libs (requires restart) |
| Enable Extensions | psql -c 'CREATE EXT ...' | Create extension objects in database |
| Update Extensions | ALTER EXTENSION UPDATE | Update packages and extension objects |
| Remove Extensions | DROP EXTENSION | Drop extension objects, uninstall pkgs |
demo/pgsql-ext.cast — /demo/pgsql-ext.cast
Install Extensions
During PostgreSQL cluster creation, the pg_extension task automatically installs extensions from pg_extensions.
To install extensions on an existing cluster, add them to all.children.<cls>.pg_extensions.
Then run:
Example: Install PostGIS, TimescaleDB and PGVector on cluster
Result: Pigsty installs extension packages on all cluster nodes. It translates package aliases to package names for the operating system and PostgreSQL version.
Before installation, verify that the nodes have the correct software repositories. Download extensions to the local repository or configure upstream repositories.
Manual Install
To install extensions without managing them in Pigsty configuration, pass the extension list on the command line:
You can also use the pig package manager CLI to install extensions on one node. It resolves package aliases automatically.
You can also use the operating system package manager directly (apt/dnf).
You must know the exact RPM or DEB package name for your operating system and PostgreSQL version:
Download Extensions
Before installation, verify that the node can get the extension from its software repositories:
- Standalone installation: The node already has the upstream repositories.
- Offline installation: The offline package contains most extensions. A few require online installation.
- Production deployment on multiple nodes with a local repository: The extension may already be downloaded. This applies if
repo_packagesorrepo_extra_packagesincluded it when you created the repository. Otherwise, download it first or configure upstream repositories for online installation.
The default Pigsty configuration downloads common extensions during installation.
For additional extensions, add them to repo_extra_packages and rebuild the repository:
Configure Repos
You can configure all nodes to install directly from upstream extension repositories. This skips the local download step. It is not recommended for production:
Configure Extensions
Some extensions must be in shared_preload_libraries.
Changes to this parameter require a database restart.
Use pg_libs to set the default list of preload extensions.
This value applies only during cluster initialization.
Changes to this value have no effect after initialization.
For existing clusters, refer to Modify Config to modify shared_preload_libraries:
Before you add preload configuration, verify that the extension packages are installed correctly.
If an extension in shared_preload_libraries is missing or cannot load, PostgreSQL will not start.
Manage cluster configuration changes through Patroni.
Avoid ALTER SYSTEM or pg_parameters for separate instance configuration changes.
Different primary and replica configurations can cause startup failure or interrupt replication.
Enable Extensions
After you install the packages, run CREATE EXTENSION in the database to enable extension features.
Enable during cluster init
Declare extensions to enable in database definition via extensions array:
Manual enable
Result: Pigsty creates extension objects in the database, such as functions, types, operators, and index methods. You can then use the extension features.
Update Extensions
Extension updates involve two layers: package update and extension object update.
Update packages
Update extension objects
Back up the database before you update extensions. Preloaded extensions may require a PostgreSQL restart after an update. Some version upgrades may be incompatible. Check the extension documentation.
Remove Extensions
Removing extensions involves two layers: drop extension objects and uninstall packages.
Drop extension objects
Remove from preload
For preloaded extensions, remove from shared_preload_libraries and restart:
Uninstall packages (optional)
CASCADE also deletes all objects that depend on the extension, such as tables, indexes, and views.
Check dependencies before you run the command.
Query Extensions
Common SQL queries for extension info:
View enabled extensions
View available extensions
Check if extension is available
View extension dependencies
View extension objects
psql shortcuts
Add Repos
To install directly from upstream, manually add repos.
Using Pigsty playbook
YUM repos (EL systems)
APT repos (Debian/Ubuntu)
FAQ
Difference between extension name and package name
| Name | Description | Example |
|---|---|---|
| Extension name | Name used with CREATE EXTENSION | vector |
| Package alias | Standardized name in Pigsty config | pgvector |
| Package name | Actual OS package name | pgvector_18* or postgresql-18-pgvector |
Preloaded extension prevents startup
If an extension in shared_preload_libraries is missing or cannot load, PostgreSQL will not start.
Use one of these solutions:
- Ensure extension package is correctly installed
- Or remove extension from
shared_preload_libraries(edit/pg/data/postgresql.conf)
Extension dependencies
Some extensions depend on other extensions.
Create the dependencies first, or use CASCADE:
Extension version incompatibility
View extension versions supported by current PostgreSQL:
Related Resources
- Extensions: Detailed extension management documentation
- Extension Catalog: Browse 600 available extensions
- pig Package Manager: Extension installation CLI tool
- Database Management: Enable extensions in databases