doc/administration/postgresql/extensions.md
{{< details >}}
{{< /details >}}
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.
Connect to the GitLab PostgreSQL database using a superuser, for example:
sudo gitlab-psql -d gitlabhq_production
Install the extension (btree_gist in this example) using
CREATE EXTENSION:
CREATE EXTENSION IF NOT EXISTS btree_gist
Verify 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.
pg_stat_statements is recommended for troubleshooting slow database queries.
Enabling it requires superuser privileges and a PostgreSQL restart.
Add pg_stat_statements to shared_preload_libraries in postgresql.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.
When working with PostgreSQL extensions, you might encounter the following issue.
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