Gismat Gusein
Gismat Gusein

Reputation: 43

Postgresql doesn't working with Citus and pg_stat_statements at the same time

So, I built the PostgreSQL with citus extension in docker. I use the official documentation in citus, then I run this command in the terminal.

docker run -d --network citus-network --name citus_coordinator -p 5500:5432 -e POSTGRES_PASSWORD=mypassword citusdata/citus:11.1

Then Database successfully building. But I want to create the pg_stat_statements extension. I configuration the postgresql.conf file.

shared_preload_libraries = 'pg_stat_statements'
pg_stat_statements.track = all
pg_stat_statements.max = 10000
track_activity_query_size = 2048

Then I restarted the PostgreSQL container. Wrote the this query

SELECT * FROM pg_stat_statements;

in terminal. I saw this error

[55000] ERROR: pg_stat_statements must be loaded via shared_preload_libraries

I didn't understand, why the config file didn't see this extension, What was my mistake?

Upvotes: 1

Views: 1065

Answers (2)

Gismat Gusein
Gismat Gusein

Reputation: 43

Solved
I am running the PostgreSQL container with postgres:latest image. Then I entered the container. So, I installed the citus from here into the container. Then installed apt-get install postgresql-contrib into the container.Next step, run create extension pg_stat_statements; And everything worked for me.

Upvotes: 1

Gledis Zeneli
Gledis Zeneli

Reputation: 131

If using citus, citus should always be your first shared preload library. So your postgres.conf should look like:

shared_preload_libraries = 'citus,pg_stat_statements'
pg_stat_statements.track = all
pg_stat_statements.max = 10000
track_activity_query_size = 2048

If you have workers, you need to change their postgresql.conf as well.

Then you need to restart the databases (coordinator and workers) which you can achieve by:

docker restart <container_name>

You can confirm this worked with:

SHOW shared_preload_libraries;

Upvotes: 1

Related Questions