Manage PostgreSQL extensions
- Tier: Free, Premium, Ultimate
- Offering: GitLab Self-Managed
GitLab requires specific PostgreSQL extensions in every database. For the list of required extensions and minimum GitLab versions, see PostgreSQL requirements.
To install extensions, PostgreSQL requires superuser privileges. The GitLab database user is typically not a superuser, so you must install extensions manually before upgrading GitLab.
Install required extensions
Connect to the GitLab PostgreSQL database using a superuser, for example:
sudo gitlab-psql -d gitlabhq_productionInstall the extension (
btree_gistin this example) usingCREATE EXTENSION:CREATE EXTENSION IF NOT EXISTS btree_gistVerify installed extensions:
gitlabhq_production=# \dx
On some systems you may need to install an additional package (for example,
postgresql-contrib) for certain extensions to become available.
Enable pg_stat_statements
pg_stat_statements is recommended for troubleshooting slow database queries.
Enabling it requires superuser privileges and a PostgreSQL restart.
Add
pg_stat_statementstoshared_preload_librariesinpostgresql.conf. For Linux package installations, add the following to/etc/gitlab/gitlab.rb:postgresql['shared_preload_libraries'] = 'pg_stat_statements'Restart PostgreSQL.
Create the extension as a superuser:
CREATE EXTENSION IF NOT EXISTS pg_stat_statements
For more information, see Enable optional query statistics data.
Troubleshooting
When working with PostgreSQL extensions, you might encounter the following issue.
Migration fails because an extension is missing
If a database migration fails because an extension is missing, install it manually as a superuser, then re-run migrations:
sudo gitlab-rake db:migrate