Managing PostgreSQL Extensions
Quick Start
Pigsty provides 575 extensions. Using extensions involves four steps: Download, Install, Configure, 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 |
Install Extensions
Extensions defined in pg_extensions are auto-installed during PostgreSQL cluster creation in the pg_extension task.
To install extensions on an existing cluster, add extensions to all.children.<cls>.pg_extensions, then execute:
Example: Install PostGIS, TimescaleDB and PGVector on cluster
Result: Installs extension packages on all cluster nodes. Pigsty auto-translates package aliases to actual package names for OS and PG version.
Before installing, ensure nodes have correct repos configured - extensions downloaded to local repo, or upstream repos configured.
Manual Install
If you don’t want to use Pigsty config to manage extensions, pass extension list directly on command line:
You can also use pig package manager CLI to install extensions on single node, with auto package alias resolution.
You can also use OS package manager directly (apt/dnf), but you must know the exact RPM/DEB package name for your OS/PG:
Download Extensions
To install extensions, ensure node’s extension repos contain the extension:
- Standalone install: No worries, upstream repos already added to node.
- Offline install: No worries, most extensions included in offline package, few require online install.
- Production multi-node deployment with local repo: depends - if extension was in
repo_packages/repo_extra_packageswhen creating local repo, it’s already downloaded. Otherwise download first or configure upstream repos for online install.
Pigsty’s default config auto-downloads mainstream extensions during installation. For additional extensions, add to repo_extra_packages and rebuild repo:
Configure Repos
You can also let all nodes use upstream repos directly (not recommended for production), skipping download and installing from upstream extension repos:
Configure Extensions
Some extensions require preloading to shared_preload_libraries, requiring database restart after modification.
Use pg_libs as its default value to configure preload extensions, but this only takes effect during cluster init - later modifications are ineffective.
For existing clusters, refer to Modify Config to modify shared_preload_libraries:
Ensure extension packages are correctly installed before adding preload config. If extension in shared_preload_libraries doesn’t exist or fails to load, PostgreSQL won’t start.
Also, manage cluster config changes through Patroni - avoid using ALTER SYSTEM or pg_parameters to modify instance config separately.
If primary and replica configs differ, it may cause startup failure or replication interruption.
Enable Extensions
After installing packages, execute CREATE EXTENSION in database to use extension features.
Enable during cluster init
Declare extensions to enable in database definition via extensions array:
Manual enable
Result: Creates extension objects (functions, types, operators, index methods, etc.) in database, enabling use of extension features.
Update Extensions
Extension updates involve two layers: package update and extension object update.
Update packages
Update extension objects
Backup database before updating extensions. Preloaded extensions may require PostgreSQL restart after update. Some extension version upgrades may be incompatible - check extension docs.
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)
Using CASCADE to drop extensions also drops all objects depending on that extension (tables, indexes, views, etc.). Check dependencies before executing.
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 extension in shared_preload_libraries doesn’t exist or fails to load, PostgreSQL won’t start. 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 others, requiring sequential creation or using CASCADE:
Extension version incompatibility
View extension versions supported by current PostgreSQL:
Related Resources
- Extensions: Detailed extension management documentation
- Extension Catalog: Browse 575 available extensions
- pig Package Manager: Extension installation CLI tool
- Database Management: Enable extensions in databases