Create Extension
CREATE EXTENSION
to actually enable a PostgreSQL extensions.Module:
After installing PostgreSQL extensions, you can view them in the pg_available_extensions
view. However, enabling these extensions typically requires additional steps:
- Some extensions must be added to the
shared_preload_libraries
for dynamic loading, such astimescaledb
andcitus
. - Most extensions need to be activated by running the SQL statement:
CREATE EXTENSION <name>;
. A few, likewal2json
, do not require this step.
Modifying shared_preload_libraries
:
- Before initializing the database cluster: You can manually specify the required libraries using the
pg_libs
parameter. - After the database cluster has been initialized: You can modify the cluster configuration by directly editing the
shared_preload_libraries
parameter and applying the changes (no restart required). - Typical extensions that require dynamic loading:
citus
,timescaledb
,pg_cron
,pg_net
,pg_tle
Executing CREATE EXTENSION
:
- Before initializing the database cluster: You can specify the required extensions in the
extensions
list withinpg_databases
. - After the database cluster has been initialized: You can directly connect to the database and execute the SQL command, or manage extensions using other schema management tools.
Conceptually: PostgreSQL extensions usually consist of three parts: a control file (metadata, always present), an SQL file (optional SQL statements), and a .so file (optional binary shared library). Extensions that provide a
.so
file may need to be added toshared_preload_libraries
to function properly, such ascitus
andtimescaledb
. However, many extensions do not require this, such aspostgis
andpgvector
. Extensions that do not expose a SQL interface do not need aCREATE EXTENSION
command to be executed, such as thewal2json
extension, which provides CDC extraction capabilities.
To complete the extension creation, execute the CREATE EXTENSION
SQL statement in the database where you wish to enable the extension.
CREATE EXTENSION vector; -- create & enable vector extension
CREATE EXTENSION hydra; -- create & enable columnar extension
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.