Last active
December 20, 2024 14:57
-
-
Save lfittl/1b0671ac07b33521ea35fcd22b0120f5 to your computer and use it in GitHub Desktop.
Enabling pg_stat_statements in a Docker container
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '2' | |
services: | |
db: | |
image: postgres:16 | |
ports: | |
- "5432:5432" | |
command: > | |
postgres | |
-c shared_preload_libraries='pg_stat_statements' | |
volumes: | |
- /var/lib/postgresql/data | |
environment: | |
POSTGRES_USER: myproject |
Found another way (it worked for me):
version: '2' services: db: image: postgres ports: - "5432:5432" volumes: - /var/lib/postgresql/data command: postgres -c shared_preload_libraries=pg_stat_statements -c pg_stat_statements.track=all -c max_connections=200 environment: POSTGRES_USER: myproject
Nice!! Worked like a charm. Thank you so much!
PS: don't forget to docker compose down
and then docker compose up
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For me, adding the commands of
pg_stat_statements
in docker-compose.yml is not workedI added manually in the
postgresql.conf
inside the docker container worked