From: | Roberto Nunnari <robi(at)nunnari(dot)ch> |
---|---|
To: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | High latency and profiling |
Date: | 2025-10-09 17:25:34 |
Message-ID: | ea4bee5e-5d78-4209-b451-50fc5d860879@nunnari.ch |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello.
Hope this email will keep the formatting this time..
I was notified about high latency on one of our PostgreSQL clusters.
This latency is observed from the application and has been increasing.
There is no indication about the exact database as the application uses
several DBs, but the largest and most used is 'mydb'.
So, a couple of months ago I installed pg_profile and configured it as
follows:
shared_preload_libraries =
'pg_stat_statements,dblink,pg_stat_kcache,pg_wait_sampling'
pg_profile.max_sample_age = 90
\c postgres
CREATE SCHEMA extensions;
CREATE EXTENSION dblink SCHEMA extensions;
CREATE EXTENSION pg_profile SCHEMA extensions;
\c mydb
CREATE SCHEMA extensions;
CREATE EXTENSION dblink SCHEMA extensions;
CREATE EXTENSION pg_stat_statements SCHEMA extensions;
CREATE EXTENSION pg_stat_kcache schema extensions;
CREATE EXTENSION pg_wait_sampling schema extensions;
CREATE EXTENSION pg_profile SCHEMA extensions;
select extensions.set_server_size_sampling('local','23:00+01',interval
'2 hour',interval '8 hour');
CREATE USER collector_user with password '';
GRANT pg_read_all_stats TO collector_user;
grant connect on database mydb to collector_user;
ALTER ROLE collector_user SET search_path = extensions,public;
The postgres user had the following crontab:
13,43 * * * * psql -d mydb -c 'SELECT extensions.take_sample()' >
/dev/null 2>&1
I made sure autovacuum works correctly and after that, just to make
sure, I run vacuum analyze on all DBs. This has not lead to any notable
improvement in the latency as seen by the application.
I access pg_profile data from grafana, but I cannot see anything that
looks wrong.
Overall Hit Ratio is always between 99.3% and 100%.
The only strange thing I see in grafana, are the following:
Overall statement times sais "No data" and 'db query error: pq: column
"blk_read_time" does not exist'. Also the graph "Statement time" says
"No data" and "db query error: pq: column sst.blk_read_time does not exist".
Wait event types (statements) graph: N/A was quite stable at about 0.200
s/s until 2nd september and then grow regularly and sharply up 4 s/s
until 22nd september when it dropped back to 0.7 s/s and is stable at
that value till now.
Developers report that their software is already optimized and database
size is not a problem. They suggest the issue might be inside PostgreSQL
itself.
Could somebody help me understand what is causing the growing latency?
Also, but more related to pg_profile, what does the N/A data in the
"Wait event types (statements)" graph represent?
Thank you and best regards.
Robi
From | Date | Subject | |
---|---|---|---|
Next Message | Laurenz Albe | 2025-10-09 19:12:07 | Re: Are compression requirements needed when building only libraries? |
Previous Message | Nathan Bossart | 2025-10-09 15:39:32 | Re: Clarification on Role Access Rights to Table Indexes |