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_librariesfor dynamic loading, such astimescaledbandcitus. - 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_libsparameter. - After the database cluster has been initialized: You can modify the cluster configuration by directly editing the
shared_preload_librariesparameter 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
extensionslist 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
.sofile may need to be added toshared_preload_librariesto function properly, such ascitusandtimescaledb. However, many extensions do not require this, such aspostgisandpgvector. Extensions that do not expose a SQL interface do not need aCREATE EXTENSIONcommand to be executed, such as thewal2jsonextension, 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.