Remove Extension

How to safely remove PostgreSQL extensions from a database cluster

Remove Extension

To uninstall an extension, you typically need to run the DROP EXTENSION statement:

DROP EXTENSION "<extname>";

Note that if other extensions or database objects depend on this extension, you’ll need to remove those dependencies first before uninstalling the extension.

Alternatively, you can forcefully uninstall the extension and all its dependencies in one operation:

DROP EXTENSION "<extname>" CASCADE;

Warning: The CASCADE option will delete all objects that depend on this extension, including database objects, functions, views, etc. Use with caution!

Not all extensions are installed via the CREATE EXTENSION statement. These extensions don’t require explicit execution of the DROP EXTENSION statement. Please refer to the Extensions Without DDL section.


Remove Loading

If you’re using an extension that requires dynamic loading (which modifies the shared_preload_libraries parameter), you need to first re-confnigure the shared_preload_libraries parameter.

Remove the extension name from shared_preload_libraries and restart the database cluster for the changes to take effect.

For extensions that need dynamic loading, refer to the Extensions that Need Loading list.


Uninstall Package

After removing the extension (logical object) from all databases in the cluster, you can safely uninstall the extension’s software package. Ansible commands can help you do this conveniently:

ansible <cls> -m package -a "name=<extname> state=absent"

You can also use pig, or apt/yum commands directly to uninstall.

If you don’t know the extension package name, you can refer to the Extension List or check the extension package name mapping defined in roles/node_id/vars.





Last modified 2025-03-21: replace vonng to pgsty (75336f2)