SlideShare a Scribd company logo
1 of 57
Download to read offline
Troubleshooting PostgreSQL
with pgCenter
Alexey Lesovsky
alexey.lesovsky@dataegret.com
dataegret.com
Introduction
• What is pgCenter.
• Goals and quick overview.
Troubleshooting cases
• Health checks and load spikes.
• Hidden problems.
• Client's activity.
• Streaming replication.
02
01
Introduction
01
• PgCenter overview.
• How to use pgCenter.
• How to troubleshoot PostgreSQL with pgCenter.
Goals01
dataegret.com
• Top-like admin tool for Postgres stats.
• Quick Postgres administration.
• Available on RHEL/CentOS/Fedora/ALT Linux/Ubuntu...
• Hosted on GitHub.
• Work in progress.
What is pgCenter01
dataegret.com
PostgreSQL Performance Views01
dataegret.com
• PostgreSQL 9.x support.
• Support of the most stats views.
• Support of the system stats.
• PostgreSQL admin tasks: configs, logs, reload, cancel/kill backends.
Features01
dataegret.com
Interface overview01
dataegret.com
pgcenter: 2017-04-05 17:40:28, load average: 1.59, 0.74, 0.42 conn1 [ok]: /run/postgresql:5433 postgres@postg (ver: 10devel, up 2 days 20:29:27)
%cpu: 14.3 us, 3.9 sy, 0.0 ni, 45.8 id, 36.0 wa, 0.0 hi, 0.0 si, 0.0 st activity: 8/100 conns, 0/0 prepared, 1 idle, 0 idle_xact, 2 active, 6 waiting, 0 others
MiB mem: 7836 total, 1582 free, 3910 used, 2344 buff/cached autovacuum: 0/3 workers/max, 0 manual, 0 wraparound, 00:00:00 vac_maxtime
MiB swap: 5119 total, 5088 free, 31 used, 26/0 dirty/writeback statements: 7050 stmt/s, 0.123 stmt_avgtime, 00:00:00 xact_maxtime, 00:00:00 prep_maxtime
user database t_all_t t_read_t t_write_t t_cpu_t all_t read_t write_t cpu_t calls queryid query
postgres pgbench 00:05:31 00:00:00 00:00:00 00:05:31 510 0 0 510 1006 08393211ce UPDATE pgbench_accounts SET abalance = abalance + $N WHERE aid = $N
postgres pgbench 00:00:09 00:00:00 00:00:00 00:00:09 14 0 0 14 1005 7c5345de88 UPDATE pgbench_branches SET bbalance = bbalance + $N WHERE bid = $N
postgres pgbench 00:00:07 00:00:00 00:00:00 00:00:07 14 0 0 14 1005 2cdaf0baaf UPDATE pgbench_tellers SET tbalance = tbalance + $N WHERE tid = $N
postgres pgbench 00:00:04 00:00:00 00:00:00 00:00:04 10 0 0 10 1005 5f72672d89 SELECT abalance FROM pgbench_accounts WHERE aid = $N
postgres pgbench 00:00:04 00:00:00 00:00:00 00:00:04 0 0 0 0 0 1097fe4e1b copy pgbench_accounts from stdin
postgres pgbench 00:00:03 00:00:00 00:00:00 00:00:03 0 0 0 0 0 3065f1faff SELECT datname, xact_commit AS commit, xact_rollback AS rollback, b
postgres pgbench 00:00:02 00:00:00 00:00:00 00:00:02 7 0 0 7 1005 f1f154154f INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES ($
postgres postgres 00:00:02 00:00:00 00:00:00 00:00:02 9 0 0 9 1 9f21a96353 SELECT a.rolname AS user, d.datname AS database, date_trunc($N, rou
postgres postgres 00:00:01 00:00:00 00:00:00 00:00:01 0 0 0 0 0 b0cfaf67a8 create database pgbench
postgres postgres 00:00:01 00:00:00 00:00:00 00:00:01 0 0 0 0 0 6441d14dc3 SELECT datname, xact_commit AS commit, xact_rollback AS rollback, b
Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await r_await w_await %util
sda: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sda1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sda2: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sdb: 0.00 6.86 0.00 288.24 0.00 2.69 19.13 0.82 2.82 0.00 2.82 82.06
sdb1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sdb2: 0.00 6.86 0.00 284.31 0.00 2.69 19.39 0.11 0.39 0.00 0.39 10.98
dm-0: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
dm-1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
dm-2: 0.00 0.00 0.00 293.14 0.00 2.68 18.70 1.66 5.62 0.00 5.62 82.16
Interface overview01
dataegret.com
pgcenter: 2017-04-05 17:40:28, load average: 1.59, 0.74, 0.42 conn1 [ok]: /run/postgresql:5433 postgres@postg (ver: 10devel, up 2 days 20:29:27)
%cpu: 14.3 us, 3.9 sy, 0.0 ni, 45.8 id, 36.0 wa, 0.0 hi, 0.0 si, 0.0 st activity: 8/100 conns, 0/0 prepared, 1 idle, 0 idle_xact, 2 active, 6 waiting, 0 others
MiB mem: 7836 total, 1582 free, 3910 used, 2344 buff/cached autovacuum: 0/3 workers/max, 0 manual, 0 wraparound, 00:00:00 vac_maxtime
MiB swap: 5119 total, 5088 free, 31 used, 26/0 dirty/writeback statements: 7050 stmt/s, 0.123 stmt_avgtime, 00:00:00 xact_maxtime, 00:00:00 prep_maxtime
user database t_all_t t_read_t t_write_t t_cpu_t all_t read_t write_t cpu_t calls queryid query
postgres pgbench 00:05:31 00:00:00 00:00:00 00:05:31 510 0 0 510 1006 08393211ce UPDATE pgbench_accounts SET abalance = abalance + $N WHERE aid = $N
postgres pgbench 00:00:09 00:00:00 00:00:00 00:00:09 14 0 0 14 1005 7c5345de88 UPDATE pgbench_branches SET bbalance = bbalance + $N WHERE bid = $N
postgres pgbench 00:00:07 00:00:00 00:00:00 00:00:07 14 0 0 14 1005 2cdaf0baaf UPDATE pgbench_tellers SET tbalance = tbalance + $N WHERE tid = $N
postgres pgbench 00:00:04 00:00:00 00:00:00 00:00:04 10 0 0 10 1005 5f72672d89 SELECT abalance FROM pgbench_accounts WHERE aid = $N
postgres pgbench 00:00:04 00:00:00 00:00:00 00:00:04 0 0 0 0 0 1097fe4e1b copy pgbench_accounts from stdin
postgres pgbench 00:00:03 00:00:00 00:00:00 00:00:03 0 0 0 0 0 3065f1faff SELECT datname, xact_commit AS commit, xact_rollback AS rollback, b
postgres pgbench 00:00:02 00:00:00 00:00:00 00:00:02 7 0 0 7 1005 f1f154154f INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES ($
postgres postgres 00:00:02 00:00:00 00:00:00 00:00:02 9 0 0 9 1 9f21a96353 SELECT a.rolname AS user, d.datname AS database, date_trunc($N, rou
postgres postgres 00:00:01 00:00:00 00:00:00 00:00:01 0 0 0 0 0 b0cfaf67a8 create database pgbench
postgres postgres 00:00:01 00:00:00 00:00:00 00:00:01 0 0 0 0 0 6441d14dc3 SELECT datname, xact_commit AS commit, xact_rollback AS rollback, b
Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await r_await w_await %util
sda: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sda1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sda2: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sdb: 0.00 6.86 0.00 288.24 0.00 2.69 19.13 0.82 2.82 0.00 2.82 82.06
sdb1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sdb2: 0.00 6.86 0.00 284.31 0.00 2.69 19.39 0.11 0.39 0.00 0.39 10.98
dm-0: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
dm-1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
dm-2: 0.00 0.00 0.00 293.14 0.00 2.68 18.70 1.66 5.62 0.00 5.62 82.16
Interface overview01
dataegret.com
pgcenter: 2017-04-05 17:40:28, load average: 1.59, 0.74, 0.42 conn1 [ok]: /run/postgresql:5433 postgres@postg (ver: 10devel, up 2 days 20:29:27)
%cpu: 14.3 us, 3.9 sy, 0.0 ni, 45.8 id, 36.0 wa, 0.0 hi, 0.0 si, 0.0 st activity: 8/100 conns, 0/0 prepared, 1 idle, 0 idle_xact, 2 active, 6 waiting, 0 others
MiB mem: 7836 total, 1582 free, 3910 used, 2344 buff/cached autovacuum: 0/3 workers/max, 0 manual, 0 wraparound, 00:00:00 vac_maxtime
MiB swap: 5119 total, 5088 free, 31 used, 26/0 dirty/writeback statements: 7050 stmt/s, 0.123 stmt_avgtime, 00:00:00 xact_maxtime, 00:00:00 prep_maxtime
user database t_all_t t_read_t t_write_t t_cpu_t all_t read_t write_t cpu_t calls queryid query
postgres pgbench 00:05:31 00:00:00 00:00:00 00:05:31 510 0 0 510 1006 08393211ce UPDATE pgbench_accounts SET abalance = abalance + $N WHERE aid = $N
postgres pgbench 00:00:09 00:00:00 00:00:00 00:00:09 14 0 0 14 1005 7c5345de88 UPDATE pgbench_branches SET bbalance = bbalance + $N WHERE bid = $N
postgres pgbench 00:00:07 00:00:00 00:00:00 00:00:07 14 0 0 14 1005 2cdaf0baaf UPDATE pgbench_tellers SET tbalance = tbalance + $N WHERE tid = $N
postgres pgbench 00:00:04 00:00:00 00:00:00 00:00:04 10 0 0 10 1005 5f72672d89 SELECT abalance FROM pgbench_accounts WHERE aid = $N
postgres pgbench 00:00:04 00:00:00 00:00:00 00:00:04 0 0 0 0 0 1097fe4e1b copy pgbench_accounts from stdin
postgres pgbench 00:00:03 00:00:00 00:00:00 00:00:03 0 0 0 0 0 3065f1faff SELECT datname, xact_commit AS commit, xact_rollback AS rollback, b
postgres pgbench 00:00:02 00:00:00 00:00:00 00:00:02 7 0 0 7 1005 f1f154154f INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES ($
postgres postgres 00:00:02 00:00:00 00:00:00 00:00:02 9 0 0 9 1 9f21a96353 SELECT a.rolname AS user, d.datname AS database, date_trunc($N, rou
postgres postgres 00:00:01 00:00:00 00:00:00 00:00:01 0 0 0 0 0 b0cfaf67a8 create database pgbench
postgres postgres 00:00:01 00:00:00 00:00:00 00:00:01 0 0 0 0 0 6441d14dc3 SELECT datname, xact_commit AS commit, xact_rollback AS rollback, b
Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await r_await w_await %util
sda: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sda1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sda2: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sdb: 0.00 6.86 0.00 288.24 0.00 2.69 19.13 0.82 2.82 0.00 2.82 82.06
sdb1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sdb2: 0.00 6.86 0.00 284.31 0.00 2.69 19.39 0.11 0.39 0.00 0.39 10.98
dm-0: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
dm-1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
dm-2: 0.00 0.00 0.00 293.14 0.00 2.68 18.70 1.66 5.62 0.00 5.62 82.16
Interface overview01
dataegret.com
pgcenter: 2017-04-05 17:40:28, load average: 1.59, 0.74, 0.42 conn1 [ok]: /run/postgresql:5433 postgres@postg (ver: 10devel, up 2 days 20:29:27)
%cpu: 14.3 us, 3.9 sy, 0.0 ni, 45.8 id, 36.0 wa, 0.0 hi, 0.0 si, 0.0 st activity: 8/100 conns, 0/0 prepared, 1 idle, 0 idle_xact, 2 active, 6 waiting, 0 others
MiB mem: 7836 total, 1582 free, 3910 used, 2344 buff/cached autovacuum: 0/3 workers/max, 0 manual, 0 wraparound, 00:00:00 vac_maxtime
MiB swap: 5119 total, 5088 free, 31 used, 26/0 dirty/writeback statements: 7050 stmt/s, 0.123 stmt_avgtime, 00:00:00 xact_maxtime, 00:00:00 prep_maxtime
user database t_all_t t_read_t t_write_t t_cpu_t all_t read_t write_t cpu_t calls queryid query
postgres pgbench 00:05:31 00:00:00 00:00:00 00:05:31 510 0 0 510 1006 08393211ce UPDATE pgbench_accounts SET abalance = abalance + $N WHERE aid = $N
postgres pgbench 00:00:09 00:00:00 00:00:00 00:00:09 14 0 0 14 1005 7c5345de88 UPDATE pgbench_branches SET bbalance = bbalance + $N WHERE bid = $N
postgres pgbench 00:00:07 00:00:00 00:00:00 00:00:07 14 0 0 14 1005 2cdaf0baaf UPDATE pgbench_tellers SET tbalance = tbalance + $N WHERE tid = $N
postgres pgbench 00:00:04 00:00:00 00:00:00 00:00:04 10 0 0 10 1005 5f72672d89 SELECT abalance FROM pgbench_accounts WHERE aid = $N
postgres pgbench 00:00:04 00:00:00 00:00:00 00:00:04 0 0 0 0 0 1097fe4e1b copy pgbench_accounts from stdin
postgres pgbench 00:00:03 00:00:00 00:00:00 00:00:03 0 0 0 0 0 3065f1faff SELECT datname, xact_commit AS commit, xact_rollback AS rollback, b
postgres pgbench 00:00:02 00:00:00 00:00:00 00:00:02 7 0 0 7 1005 f1f154154f INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES ($
postgres postgres 00:00:02 00:00:00 00:00:00 00:00:02 9 0 0 9 1 9f21a96353 SELECT a.rolname AS user, d.datname AS database, date_trunc($N, rou
postgres postgres 00:00:01 00:00:00 00:00:00 00:00:01 0 0 0 0 0 b0cfaf67a8 create database pgbench
postgres postgres 00:00:01 00:00:00 00:00:00 00:00:01 0 0 0 0 0 6441d14dc3 SELECT datname, xact_commit AS commit, xact_rollback AS rollback, b
Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await r_await w_await %util
sda: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sda1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sda2: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sdb: 0.00 6.86 0.00 288.24 0.00 2.69 19.13 0.82 2.82 0.00 2.82 82.06
sdb1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sdb2: 0.00 6.86 0.00 284.31 0.00 2.69 19.39 0.11 0.39 0.00 0.39 10.98
dm-0: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
dm-1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
dm-2: 0.00 0.00 0.00 293.14 0.00 2.68 18.70 1.66 5.62 0.00 5.62 82.16
Interface overview01
dataegret.com
pgcenter: 2017-04-05 17:40:28, load average: 1.59, 0.74, 0.42 conn1 [ok]: /run/postgresql:5433 postgres@postg (ver: 10devel, up 2 days 20:29:27)
%cpu: 14.3 us, 3.9 sy, 0.0 ni, 45.8 id, 36.0 wa, 0.0 hi, 0.0 si, 0.0 st activity: 8/100 conns, 0/0 prepared, 1 idle, 0 idle_xact, 2 active, 6 waiting, 0 others
MiB mem: 7836 total, 1582 free, 3910 used, 2344 buff/cached autovacuum: 0/3 workers/max, 0 manual, 0 wraparound, 00:00:00 vac_maxtime
MiB swap: 5119 total, 5088 free, 31 used, 26/0 dirty/writeback statements: 7050 stmt/s, 0.123 stmt_avgtime, 00:00:00 xact_maxtime, 00:00:00 prep_maxtime
user database t_all_t t_read_t t_write_t t_cpu_t all_t read_t write_t cpu_t calls queryid query
postgres pgbench 00:05:31 00:00:00 00:00:00 00:05:31 510 0 0 510 1006 08393211ce UPDATE pgbench_accounts SET abalance = abalance + $N WHERE aid = $N
postgres pgbench 00:00:09 00:00:00 00:00:00 00:00:09 14 0 0 14 1005 7c5345de88 UPDATE pgbench_branches SET bbalance = bbalance + $N WHERE bid = $N
postgres pgbench 00:00:07 00:00:00 00:00:00 00:00:07 14 0 0 14 1005 2cdaf0baaf UPDATE pgbench_tellers SET tbalance = tbalance + $N WHERE tid = $N
postgres pgbench 00:00:04 00:00:00 00:00:00 00:00:04 10 0 0 10 1005 5f72672d89 SELECT abalance FROM pgbench_accounts WHERE aid = $N
postgres pgbench 00:00:04 00:00:00 00:00:00 00:00:04 0 0 0 0 0 1097fe4e1b copy pgbench_accounts from stdin
postgres pgbench 00:00:03 00:00:00 00:00:00 00:00:03 0 0 0 0 0 3065f1faff SELECT datname, xact_commit AS commit, xact_rollback AS rollback, b
postgres pgbench 00:00:02 00:00:00 00:00:00 00:00:02 7 0 0 7 1005 f1f154154f INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES ($
postgres postgres 00:00:02 00:00:00 00:00:00 00:00:02 9 0 0 9 1 9f21a96353 SELECT a.rolname AS user, d.datname AS database, date_trunc($N, rou
postgres postgres 00:00:01 00:00:00 00:00:00 00:00:01 0 0 0 0 0 b0cfaf67a8 create database pgbench
postgres postgres 00:00:01 00:00:00 00:00:00 00:00:01 0 0 0 0 0 6441d14dc3 SELECT datname, xact_commit AS commit, xact_rollback AS rollback, b
Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await r_await w_await %util
sda: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sda1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sda2: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sdb: 0.00 6.86 0.00 288.24 0.00 2.69 19.13 0.82 2.82 0.00 2.82 82.06
sdb1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sdb2: 0.00 6.86 0.00 284.31 0.00 2.69 19.39 0.11 0.39 0.00 0.39 10.98
dm-0: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
dm-1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
dm-2: 0.00 0.00 0.00 293.14 0.00 2.68 18.70 1.66 5.62 0.00 5.62 82.16
pg_stat_database.
pg_stat_replication.
pg_stat_user_tables, pg_statio_user_tables.
pg_stat_user_indexes, pg_statio_user_indexes.
pg_stat_user_functions.
pg_stat_activity, pg_stat_progress_vacuum.
pg_stat_statement.
Supported stats01
dataegret.com
• Iostat – storage devices stats.
• Nicstat – network interfaces stats.
• Log tail – latest lines from postgres logs.
Additional stats01
dataegret.com
Troubleshooting
cases
02
• Health checks and load spikes.
• Hidden problems.
• Clients' activity.
• Streaming replication.
Troubleshooting cases02
dataegret.com
Check whether is everything OK?
or
When something really goes wrong.
Health checks or load spikes02
dataegret.com
Run pgCenter.
Check system resources (cpu, memory/swap, storage, network).
Check postgres activity (conn's states, xact age).
Check iostat/nicstat if required.
Health checks and load spikes02
dataegret.com
Health checks and load spikes02
dataegret.com
pgcenter: 2017-04-07 21:50:36, load average: 4.14, 0.98, 0.46 conn1 [ok]: /var/run/postgresql:5432 postgres@p (ver: 9.6.2, up 1 day 04:02:57)
%cpu: 2.9 us, 0.7 sy, 0.0 ni, 11.4 id, 85.0 wa, 0.0 hi, 0.0 si, 0.0 st activity: 13/100 conns, 0/0 prepared, 0 idle, 0 idle_xact, 13 active, 0 waiting, 0 others
MiB mem: 32124 total, 6228 free, 25464 used, 432 buff/cached autovacuum: 0/3 workers/max, 0 manual, 0 wraparound, 00:00:00 vac_maxtime
MiB swap: 15257 total, 15257 free, 0 used, 1/0 dirty/writeback statements: 3519 stmt/s, 0.263 stmt_avgtime, 00:00:00 xact_maxtime, 00:00:00 prep_maxtime
datname commit rollback reads hits returned fetched inserts updates deletes conflicts deadlocks tmp_files tmp_bytes read_t write_t
pgbench_64gb 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
pgbench_6gb 2 0 0 69 999 11 0 0 0 0 0 0 0 0 0
postgres 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0
template0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await r_await w_await %util
sda: 0.00 3.92 841.18 20.59 6.57 3.75 24.52 11.63 13.44 13.77 0.19 99.22
sda1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sda2: 0.00 3.92 841.18 20.59 6.57 3.75 24.52 11.59 13.44 13.77 0.19 99.22
sdb: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sdb1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
Health checks and load spikes02
dataegret.com
pgcenter: 2017-04-07 21:50:36, load average: 4.14, 0.98, 0.46 conn1
%cpu: 2.9 us, 0.7 sy, 0.0 ni, 11.4 id, 85.0 wa, 0.0 hi, 0.0 si, 0.0 st act
MiB mem: 32124 total, 6228 free, 25464 used, 432 buff/cached autov
MiB swap: 15257 total, 15257 free, 0 used, 1/0 dirty/writeback state
datname commit rollback reads hits returned fetched inserts updates delete
pgbench_64gb 0 0 0 0 0 0 0 0 0
pgbench_6gb 2 0 0 69 999 11 0 0 0
postgres 6 0 0 0 0 0 0 0 0
template0 0 0 0 0 0 0 0 0 0
Health checks and load spikes02
dataegret.com
conn1 [ok]: /var/run/postgresql:5432 postgres@p (ver: 9.6.2, up 1 day 04:02:57)
activity: 13/100 conns, 0/0 prepared, 0 idle, 0 idle_xact, 13 active, 0 waiting, 0 others
autovacuum: 0/3 workers/max, 0 manual, 0 wraparound, 00:00:00 vac_maxtime
statements: 3519 stmt/s, 0.263 stmt_avgtime, 00:00:00 xact_maxtime, 00:00:00 prep_maxtime
s deletes conflicts deadlocks tmp_files tmp_bytes read_t write_t
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
Health checks and load spikes02
dataegret.com
Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await r_await w_await %util
sda: 0.00 3.92 841.18 20.59 6.57 3.75 24.52 11.63 13.44 13.77 0.19 99.22
sda1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sda2: 0.00 3.92 841.18 20.59 6.57 3.75 24.52 11.59 13.44 13.77 0.19 99.22
sdb: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sdb1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
Which queries cause the load?
Go into details02
dataegret.com
pg_stat_statements is a contrib module.
GUCs:
shared_preload_libraries = 'pg_stat_statements'
track_io_timing = on
Available stats in pgCenter:
timings - how long queries have run;
general - number of calls and rows;
IO - buffers, temp, local IO.
pg_stat_statements02
dataegret.com
Health checks and load spikes02
dataegret.com
pgcenter: 2017-04-07 21:50:36, load average: 4.14, 0.98, 0.46 conn1 [ok]: /var/run/postgresql:5432 postgres@p (ver: 9.6.2, up 1 day 04:02:57)
%cpu: 2.9 us, 0.7 sy, 0.0 ni, 11.4 id, 85.0 wa, 0.0 hi, 0.0 si, 0.0 st activity: 13/100 conns, 0/0 prepared, 0 idle, 0 idle_xact, 13 active, 0 waiting, 0 others
MiB mem: 32124 total, 6228 free, 25464 used, 432 buff/cached autovacuum: 0/3 workers/max, 0 manual, 0 wraparound, 00:00:00 vac_maxtime
MiB swap: 15257 total, 15257 free, 0 used, 1/0 dirty/writeback statements: 3519 stmt/s, 0.263 stmt_avgtime, 00:00:00 xact_maxtime, 00:00:00 prep_maxtime
user database t_all_t t_read_t t_write_t t_cpu_t all_t read_t write_t cpu_t calls queryid query
postgres pgbench_64gb 47:38:04 47:33:07 00:00:00 00:04:57 7868 7855 0 12 405 94ffafcb30 UPDATE pgbench_accounts SET abalance = abalance + ? WHERE aid =
postgres pgbench_64gb 23:51:51 23:48:08 00:00:00 00:03:42 5 0 0 6 405 111df3ad65 SELECT abalance FROM pgbench_accounts WHERE aid = ?;
postgres pgbench_6gb 02:14:23 00:02:45 00:00:00 02:11:38 0 0 0 0 0 e8e1cdb2da SELECT abalance FROM pgbench_accounts WHERE aid = 7287471;
postgres pgbench_64gb 00:01:31 00:00:18 00:00:00 00:01:13 6 0 0 6 405 45b6b13d62 UPDATE pgbench_tellers SET tbalance = tbalance + ? WHERE tid = ?
postgres pgbench_6gb 01:07:36 00:00:16 00:00:00 01:07:19 0 0 0 0 0 192353e099 UPDATE pgbench_accounts SET abalance = abalance + ? WHERE aid =
postgres pgbench_64gb 00:01:22 00:00:08 00:00:00 00:01:13 6 0 0 6 405 e192b43faf UPDATE pgbench_branches SET bbalance = bbalance + ? WHERE bid =
okagent pgbench_6gb 00:00:00 00:00:00 00:00:00 00:00:00 0 0 0 0 0 f67e66660a select * from pg_stat_user_tables s limit ?
postgres pgbench_6gb 00:00:00 00:00:00 00:00:00 00:00:00 0 0 0 0 0 f6241e76ed vacuum pgbench_branches
postgres pgbench_64gb 00:00:00 00:00:00 00:00:00 00:00:00 0 0 0 0 0 eaf8d3d459 truncate pgbench_history
postgres pgbench_64gb 00:00:42 00:00:00 00:00:00 00:00:42 4 0 0 3 405 e7cc060768 INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES
postgres pgbench_6gb 00:30:17 00:00:00 00:00:00 00:30:17 0 0 0 0 0 e7766dd7c6 UPDATE pgbench_branches SET bbalance = bbalance + ? WHERE bid =
okagent pgbench_64gb 00:00:02 00:00:00 00:00:00 00:00:02 0 0 0 0 0 de77700d35 SELECT schemaname, relname, indexrelname, coalesce(pg_relation_
okagent pgbench_64gb 00:00:02 00:00:00 00:00:00 00:00:02 0 0 0 0 0 d1bcc9180b SELECT schemaname, relname, coalesce(heap_blks_read,?) as heap_
postgres pgbench_64gb 00:00:00 00:00:00 00:00:00 00:00:00 0 0 0 0 0 d101ae1052 vacuum pgbench_branches
Health checks and load spikes02
dataegret.com
oad average: 4.14, 0.98, 0.46 conn1 [ok]: /var/run/postgresql:5432 postgres@p (ver: 9.6.2, up 1 day 04:02:57)
ni, 11.4 id, 85.0 wa, 0.0 hi, 0.0 si, 0.0 st activity: 13/100 conns, 0/0 prepared, 0 idle, 0 idle_xact, 13 active, 0 waiting, 0 others
ree, 25464 used, 432 buff/cached autovacuum: 0/3 workers/max, 0 manual, 0 wraparound, 00:00:00 vac_maxtime
ree, 0 used, 1/0 dirty/writeback statements: 3519 stmt/s, 0.263 stmt_avgtime, 00:00:00 xact_maxtime, 00:00:00 prep_maxtime
t_read_t t_write_t t_cpu_t all_t read_t write_t cpu_t calls queryid query
47:33:07 00:00:00 00:04:57 7868 7855 0 12 405 94ffafcb30 UPDATE pgbench_accounts SET abalance = abalance + ? WHERE aid =
23:48:08 00:00:00 00:03:42 5 0 0 6 405 111df3ad65 SELECT abalance FROM pgbench_accounts WHERE aid = ?;
00:02:45 00:00:00 02:11:38 0 0 0 0 0 e8e1cdb2da SELECT abalance FROM pgbench_accounts WHERE aid = 7287471;
00:00:18 00:00:00 00:01:13 6 0 0 6 405 45b6b13d62 UPDATE pgbench_tellers SET tbalance = tbalance + ? WHERE tid = ?
00:00:16 00:00:00 01:07:19 0 0 0 0 0 192353e099 UPDATE pgbench_accounts SET abalance = abalance + ? WHERE aid =
00:00:08 00:00:00 00:01:13 6 0 0 6 405 e192b43faf UPDATE pgbench_branches SET bbalance = bbalance + ? WHERE bid =
00:00:00 00:00:00 00:00:00 0 0 0 0 0 f67e66660a select * from pg_stat_user_tables s limit ?
00:00:00 00:00:00 00:00:00 0 0 0 0 0 f6241e76ed vacuum pgbench_branches
00:00:00 00:00:00 00:00:00 0 0 0 0 0 eaf8d3d459 truncate pgbench_history
00:00:00 00:00:00 00:00:42 4 0 0 3 405 e7cc060768 INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES
00:00:00 00:00:00 00:30:17 0 0 0 0 0 e7766dd7c6 UPDATE pgbench_branches SET bbalance = bbalance + ? WHERE bid =
00:00:00 00:00:00 00:00:02 0 0 0 0 0 de77700d35 SELECT schemaname, relname, indexrelname, coalesce(pg_relation_
00:00:00 00:00:00 00:00:02 0 0 0 0 0 d1bcc9180b SELECT schemaname, relname, coalesce(heap_blks_read,?) as heap_
00:00:00 00:00:00 00:00:00 0 0 0 0 0 d101ae1052 vacuum pgbench_branches
Another example.
Health checks and load spikes02
dataegret.com
Health checks and load spikes02
dataegret.com
pgcenter: 2017-04-07 21:52:54, load average: 10.65, 4.65, 1.89 conn1 [ok]: /var/run/postgresql:5432 postgres@p (ver: 9.6.2, up 1 day 04:05:15)
%cpu: 77.4 us, 9.6 sy, 0.0 ni, 12.9 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st activity: 73/100 conns, 0/0 prepared, 12 idle, 0 idle_xact, 61 active, 0 waiting, 0 others
MiB mem: 32124 total, 215 free, 25469 used, 6440 buff/cached autovacuum: 0/3 workers/max, 0 manual, 0 wraparound, 00:00:00 vac_maxtime
MiB swap: 15257 total, 15257 free, 0 used, 0/0 dirty/writeback statements: 76074 stmt/s, 0.263 stmt_avgtime, 00:00:00 xact_maxtime, 00:00:00 prep_maxtime
user database t_all_t t_read_t t_write_t t_cpu_t all_t read_t write_t cpu_t calls queryid query
postgres pgbench_6gb 02:14:30 00:02:45 00:00:00 02:11:45 909 0 0 909 63551 e8e1cdb2da SELECT abalance FROM pgbench_accounts WHERE aid = 7287471;
postgres pgbench_6gb 01:07:36 00:00:16 00:00:00 01:07:19 0 0 0 0 0 192353e099 UPDATE pgbench_accounts SET abalance = abalance + ? WHERE aid =
postgres pgbench_6gb 00:30:17 00:00:00 00:00:00 00:30:17 0 0 0 0 0 e7766dd7c6 UPDATE pgbench_branches SET bbalance = bbalance + ? WHERE bid =
postgres pgbench_6gb 00:29:07 00:00:00 00:00:00 00:29:07 0 0 0 0 0 5372cff023 UPDATE pgbench_tellers SET tbalance = tbalance + ? WHERE tid = ?
postgres pgbench_6gb 00:16:05 00:00:00 00:00:00 00:16:05 0 0 0 0 0 7a4d34a918 INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES
postgres pgbench_64gb 47:40:16 47:35:18 00:00:00 00:04:57 0 0 0 0 0 94ffafcb30 UPDATE pgbench_accounts SET abalance = abalance + ? WHERE aid =
postgres pgbench_64gb 23:51:51 23:48:08 00:00:00 00:03:42 0 0 0 0 0 111df3ad65 SELECT abalance FROM pgbench_accounts WHERE aid = ?;
postgres pgbench_64gb 00:01:22 00:00:08 00:00:00 00:01:13 0 0 0 0 0 e192b43faf UPDATE pgbench_branches SET bbalance = bbalance + ? WHERE bid =
postgres pgbench_64gb 00:01:31 00:00:18 00:00:00 00:01:13 0 0 0 0 0 45b6b13d62 UPDATE pgbench_tellers SET tbalance = tbalance + ? WHERE tid = ?
postgres pgbench_64gb 00:00:42 00:00:00 00:00:00 00:00:42 0 0 0 0 0 e7cc060768 INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES
postgres pgbench_6gb 00:00:41 00:00:00 00:00:00 00:00:41 0 0 0 0 0 7cbfcd7045 END;
postgres pgbench_6gb 00:00:35 00:00:00 00:00:00 00:00:35 0 0 0 0 0 250dbbb915 BEGIN;
Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await r_await w_await %util
sda: 0.00 0.00 0.00 28.71 0.00 0.22 16.00 0.00 0.00 0.00 0.00 0.00
sda1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sda2: 0.00 0.00 0.00 28.71 0.00 0.22 16.00 0.00 0.00 0.00 0.00 0.00
sdb: 0.00 0.99 17.82 0.00 0.15 0.00 16.89 0.00 0.22 0.22 0.00 0.40
sdb1: 0.00 0.99 17.82 0.00 0.15 0.00 16.89 0.00 0.22 0.22 0.00 0.40
Reports based on pg_stat_statements.
Use queryid and "G" hotkey.
pg_stat_statements reports02
dataegret.com
IO consuming query02
dataegret.com
summary:
total_time: 75:59:21, cpu_time: 04:50:58, io_time: 71:08:23
(ALL: 100.00%, CPU: 6.38%, IO: 93.62%),
total queries: 1,090,573,273
query info:
usename: postgres,
datname: pgbench_64gb,
calls (relative to all queries): 4,826,787 (0.44%),
rows (relative to all queries): 4,826,787 (0.53%),
total time (relative to all queries): 47:21:38 (ALL: 62.3%, CPU: 1.7%, IO: 66.5%),
average time (only for this query): 35.32ms, cpu_time: 0.06ms, io_time: 35.26ms,
(ALL: 100.0%, CPU: 0.2%, IO: 99.8%),
query text (id: 94ffafcb30):
UPDATE pgbench_accounts SET abalance = abalance + ? WHERE aid = ?;
CPU consuming query02
dataegret.com
summary:
total_time: 75:56:34, cpu_time: 04:50:04, io_time: 71:06:29
(ALL: 100.00%, CPU: 6.37%, IO: 93.63%),
total queries: 1,087,323,630
query info:
usename: postgres,
datname: pgbench_6gb,
calls (relative to all queries): 531,640,449 (48.89%),
rows (relative to all queries): 531,640,449 (58.59%),
total time (relative to all queries): 02:12:35 (ALL: 2.9%, CPU: 44.8%, IO: 0.1%),
average time (only for this query): 0.01ms, cpu_time: 0.01ms, io_time: 0.00ms,
(ALL: 100.0%, CPU: 100.0%, IO: 0.0%),
query text (id: e8e1cdb2da):
SELECT abalance FROM pgbench_accounts WHERE aid = 7287471;
using pg_stat_statements you able to find:
• frequently called queries;
• queries that return highest number of rows;
• queries caused buffers IO;
• cpu hog queries;
• disk hog queries (read/write);
• queries with IO on temp files;
• queries with IO on temp tables;
• use sorting and filtering;
• reports.
pg_stat_statements summary02
dataegret.com
• Health checks and load spikes.
• Hidden problems.
• Clients' activity.
• Streaming replication.
Troubleshooting cases02
dataegret.com
Sequential scans.
Database’s unwanted events.
Unused indexes.
Tables' sizes.
Hidden problems02
dataegret.com
Sequential scans:
• might increase time of query execution;
• extra IO impact on large tables.
But OK for OLAP workload.
Sequential scans02
dataegret.com
Sequential scans02
dataegret.com
pgcenter: 2017-04-08 11:10:14, load average: 3.09, 1.03, 0.37 conn1 [ok]: /var/run/postgresql:5432
%cpu: 91.8 us, 0.2 sy, 0.0 ni, 8.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st activity: 12/100 conns, 0/0 prepa
MiB mem: 32124 total, 291 free, 25471 used, 6362 buff/cached autovacuum: 0/3 workers/max, 0 man
MiB swap: 15257 total, 15257 free, 0 used, 0/0 dirty/writeback statements: 0 stmt/s, 0.000 stmt_a
relation seq_scan seq_read idx_scan idx_fetch inserts updates deletes hot_updates live dead
public.ycsb_metrics 43 43000000 129 4397052 0 0 0 0 0 0
public.pgbench_tellers 0 0 0 0 0 0 0 0 0 0
public.pgbench_history 0 0 0 0 0 0 0 0 0 0
public.pgbench_branches 0 0 0 0 0 0 0 0 0 0
public.pgbench_accounts 0 0 0 0 0 0 0 0 0 0
Sequential scans02
dataegret.com
pgcenter: 2017-04-08 11:10:50, load average: 6.73, 2.17, 0.78 conn1 [ok]: /var/run/postgresql:5432
%cpu: 91.6 us, 0.2 sy, 0.0 ni, 8.3 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st activity: 12/100 conns, 0/0 prepa
MiB mem: 32124 total, 290 free, 25471 used, 6363 buff/cached autovacuum: 0/3 workers/max, 0 man
MiB swap: 15257 total, 15257 free, 0 used, 0/0 dirty/writeback statements: 0 stmt/s, 0.000 stmt_a
relation heap_read heap_hit idx_read idx_hit toast_read toast_hit tidx_read tidx_hit
public.ycsb_metrics 0 7675872 0 93752 0 0 0 0
public.pgbench_tellers 0 0 0 0 0 0 0 0
public.pgbench_history 0 0 0 0 0 0 0 0
public.pgbench_branches 0 0 0 0 0 0 0 0
public.pgbench_accounts 0 0 0 0 0 0 0 0
Sequential scans02
dataegret.com
pgcenter: 2017-04-08 11:13:02, load average: 10.66, 5.43, 2.18 conn1 [ok]: /var/run/postgresql:5432 postgres@p (ver: 9.6.2, up 1 day
%cpu: 91.9 us, 0.3 sy, 0.0 ni, 7.8 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st activity: 12/100 conns, 0/0 prepared, 0 idle, 0 idle_xact, 12 active,
MiB mem: 32124 total, 286 free, 25475 used, 6363 buff/cached autovacuum: 0/3 workers/max, 0 manual, 0 wraparound, 00:00:00
MiB swap: 15257 total, 15257 free, 0 used, 0/0 dirty/writeback statements: 160 stmt/s, 0.253 stmt_avgtime, 00:00:00 xact_maxtime, 00:00:00
user database t_calls t_rows calls rows queryid query
postgres pgbench_6gb 11191 11186446 38 38292 3702386801 select id,inserted_at,severity,payload from ycsb_metrics where ycsb_sensor = ?;
postgres pgbench_6gb 11220 1122000 38 3800 e55c44ee4a select id,ycsb_sensor,extra1 from ycsb_metrics where severity = ? order by inserted_at
postgres pgbench_6gb 11221 1122010 38 3800 18d47af42e select id,inserted_at,severity,payload,extra1,extra2,extra3 from ycsb_metrics where
postgres pgbench_6gb 54 6425 1 119 3cadff41ef SELECT a.rolname AS user, d.datname AS database, sum(p.calls) AS t_calls, sum(p.rows)
postgres pgbench_6gb 11224 11224 39 39 65087e0adb select ycsb_sensor,inserted_at,severity,payload from ycsb_metrics where id = ?;
Rollbacks.
Deadlocks.
Temporary files.
Recovery conflicts.
Unwanted events02
dataegret.com
Unwanted events02
dataegret.com
pgcenter: 2017-04-08 11:40:07, load average: 10.56, 4.80, 2.28 conn1 [ok]: /var/run/postgresql:5432 postgres@p (ver: 9.6.2, up 1 day
%cpu: 91.9 us, 2.6 sy, 0.0 ni, 5.5 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st activity: 12/100 conns, 0/0 prepared, 7 idle, 0 idle_xact, 5 active,
MiB mem: 32124 total, 267 free, 25475 used, 6382 buff/cached autovacuum: 0/3 workers/max, 0 manual, 0 wraparound, 00:00:00
MiB swap: 15257 total, 15257 free, 0 used, 0/0 dirty/writeback statements: 3535 stmt/s, 0.255 stmt_avgtime, 00:00:00 xact_maxtime,
datname commit rollback reads hits returned fetched inserts updates deletes conflicts deadlocks tmp_files tmp_bytes read_t write_t
pgbench_64gb 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
pgbench_6gb 154 37 0 918112 40826627 3826627 22 1 0 0 0 0 0 0 0
postgres 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
template0 2 0 0 69 978 11 0 0 0 0 0 0 0 0 0
template1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Rollbacks - check postgres logs and application.
Deadlocks - enable log_lock_waits, check logs.
Temp files - enable log_temp_files, check logs, pg_stat_statements.
Recovery conflicts - check postgres logs, standby’s queries.
Unwanted events summary02
dataegret.com
Unused indexes are bad:
• consume disk space;
• extra writes operations;
• slow down INSERT/UPDATE/DELETEs;
• extra work for (auto)VACUUM.
Unused indexes02
dataegret.com
Unused indexes02
dataegret.com
pgcenter: 2017-04-08 11:45:20, load average: 0.09, 2.08, 1.87 conn1 [ok]: /var/run/postgresql:5432 postgre
%cpu: 0.2 us, 0.0 sy, 0.0 ni, 99.8 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st activity: 1/100 conns, 0/0 prepared, 0
MiB mem: 32124 total, 282 free, 25462 used, 6380 buff/cached autovacuum: 0/3 workers/max, 0 manual, 0
MiB swap: 15257 total, 15257 free, 0 used, 0/0 dirty/writeback statements: 6 stmt/s, 0.255 stmt_avgtime,
relation index idx_scan idx_tup_read idx_tup_fetch idx_read idx_hit
public.ycsb_metrics ycsb_metrics_ycsb_sensor_idx 0 0 0 0 0
public.ycsb_metrics ycsb_metrics_severity_idx 0 0 0 0 0
public.ycsb_metrics ycsb_metrics_pkey 0 0 0 0 0
public.ycsb_metrics ycsb_metrics_inserted_at_idx 0 0 0 0 0
public.pgbench_tellers pgbench_tellers_pkey 0 0 0 0 0
public.pgbench_branches pgbench_branches_pkey 0 0 0 0 0
public.pgbench_accounts pgbench_accounts_pkey 0 0 0 0 0
How fast do tables and their indexes grow?
• pg_relation_size();
• pg_total_relation_size();
• pg_stat_user_tables.
Tables' sizes02
dataegret.com
Table’s sizes02
dataegret.com
pgcenter: 2017-04-08 12:03:55, load average: 3.29, 0.85, 0.81
%cpu: 79.1 us, 8.8 sy, 0.0 ni, 12.1 id, 0.0 wa, 0.0 hi, 0.1 si, 0.0 st
MiB mem: 32124 total, 230 free, 25471 used, 6423 buff/cached
MiB swap: 15257 total, 15257 free, 0 used, 29/0 dirty/writeback
relation total_size rel_size idx_size total_change rel_change idx_change
public.ycsb_metrics 362800 237312 125488 4208 2464 1744
public.pgbench_tellers 2984 2160 824 0 0 0
public.pgbench_history 0 0 0 0 0 0
public.pgbench_branches 1944 1624 320 0 0 0
public.pgbench_accounts 6934296 5967448 966848 0 0 0
These are not all cases.
There are many other use cases.
Hidden problems summary02
dataegret.com
• Health checks and load spikes.
• Hidden problems.
• Clients' activity.
• Streaming replication.
Troubleshooting cases02
dataegret.com
A lot of active clients.
Idle transactions.
Waiting clients.
Age of the longest transaction.
Autovacuum.
Clients' activity02
dataegret.com
Clients' activity02
dataegret.com
pgcenter: 2017-04-08 14:02:32, load average: 12.65, 10.19, 5.50 conn1 [ok]: /var/run/postgresql:5432 postgres@p (ver: 9.6.2, up 1 day 20:14:53)
%cpu: 69.0 us, 10.5 sy, 0.0 ni, 20.3 id, 0.2 wa, 0.0 hi, 0.0 si, 0.0 st activity: 11/100 conns, 0/0 prepared, 0 idle, 0 idle_xact, 11 active, 3 waiting, 0 others
MiB mem: 32124 total, 224 free, 25466 used, 6434 buff/cached autovacuum: 0/3 workers/max, 0 manual, 0 wraparound, 00:00:00 vac_maxtime
MiB swap: 15257 total, 15257 free, 0 used, 1/0 dirty/writeback statements: 80598 stmt/s, 0.246 stmt_avgtime, 00:00:00 xact_maxtime, 00:00:00 prep_maxtime
pid cl_addr cl_port datname usename state wait_etype wait_event xact_age query_age change_age query
21304 -1 pgbench_6gb postgres active 00:00:00 00:00:00 00:00:00 UPDATE pgbench_accounts SET abalance = abalance + 2099 WH
21303 -1 pgbench_6gb postgres active 00:00:00 00:00:00 00:00:00 UPDATE pgbench_accounts SET abalance = abalance + 1822 WH
21302 -1 pgbench_6gb postgres active 00:00:00 00:00:00 00:00:00 UPDATE pgbench_accounts SET abalance = abalance + 1989 WH
21301 -1 pgbench_6gb postgres active 00:00:00 00:00:00 00:00:00 UPDATE pgbench_accounts SET abalance = abalance + 2305 WH
21300 -1 pgbench_6gb postgres active LWLockNamed XidGenLock 00:00:00 00:00:00 00:00:00 UPDATE pgbench_accounts SET abalance = abalance + 762 WHE
21299 -1 pgbench_6gb postgres active 00:00:00 00:00:00 00:00:00 UPDATE pgbench_accounts SET abalance = abalance + 771 WHE
21298 -1 pgbench_6gb postgres active LWLockTranche buffer_content 00:00:00 00:00:00 00:00:00 UPDATE pgbench_accounts SET abalance = abalance + 4219 WH
21297 -1 pgbench_6gb postgres active 00:00:00 00:00:00 00:00:00 UPDATE pgbench_accounts SET abalance = abalance + -2077 W
21296 -1 pgbench_6gb postgres active 00:00:00 00:00:00 00:00:00 UPDATE pgbench_accounts SET abalance = abalance + -2311 W
21295 -1 pgbench_6gb postgres active LWLockNamed XidGenLock 00:00:00 00:00:00 00:00:00 UPDATE pgbench_accounts SET abalance = abalance + 4555 WH
Avoid:
• idle and long transactions cause bloat;
• deadlocks frustrate users.
Possible solutuions:
• cancel or terminate them;
• inspect an application.
Clients' activity summary02
dataegret.com
• Health checks and load spikes.
• Hidden problems.
• Clients' activity.
• Streaming replication.
Troubleshooting cases02
dataegret.com
Replication issues:
• replication lag;
• standby’s queries.
Streaming replication02
dataegret.com
pg_stat_replication & co02
dataegret.com
pgcenter: 2017-04-08 14:13:49, load average: 0.04, 3.10, 4.61 conn1 [ok]: /var/run/postgresql:5432 postgres@p
%cpu: 0.0 us, 0.1 sy, 0.0 ni, 99.9 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st activity: 1/100 conns, 0/0 prepared, 0 idle,
MiB mem: 32124 total, 232 free, 25461 used, 6431 buff/cached autovacuum: 0/3 workers/max, 0 manual, 0 wra
MiB swap: 15257 total, 15257 free, 0 used, 0/0 dirty/writeback statements: 6 stmt/s, 0.241 stmt_avgtime, 00:
client user name state mode xlog pending write flush replay total_lag xact_age time_age
10.6.6.9 replica walreceiver streaming async 2485 0 0 0 410480 410480 524824 00:02:14
10.6.6.7 replica walreceiver streaming async 2485 0 0 0 0 0
10.6.6.6 replica walreceiver streaming async 2485 0 0 0 128 128 14 00:00:01
• Health checks and load spikes.
• Hidden problems.
• Clients activity.
• Streaming replication.
Troubleshooting cases02
dataegret.com
Postgres offers a lot of stats.
pgCenter offers handy stats' representation.
pgCenter helps to solve many types of issues.
It's still work in progress.
Summary02
dataegret.com
pgCener – https://github.com/lesovsky/pgcenter
Slides – https://slideshare.net/alexeylesovsky/presentations
DataEgret – http://dataegret.com
DataEgret Blog – https://blog.postgresql-consulting.com
Links02
dataegret.com
Thanks for watching!
dataegret.com alexey.lesovsky@dataegret.com

More Related Content

What's hot

How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015
How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015
How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015PostgreSQL-Consulting
 
PostgreSQL Streaming Replication Cheatsheet
PostgreSQL Streaming Replication CheatsheetPostgreSQL Streaming Replication Cheatsheet
PostgreSQL Streaming Replication CheatsheetAlexey Lesovsky
 
Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Alexey Lesovsky
 
PostgreSQL Administration for System Administrators
PostgreSQL Administration for System AdministratorsPostgreSQL Administration for System Administrators
PostgreSQL Administration for System AdministratorsCommand Prompt., Inc
 
collectd & PostgreSQL
collectd & PostgreSQLcollectd & PostgreSQL
collectd & PostgreSQLMark Wong
 
SCALE 15x Minimizing PostgreSQL Major Version Upgrade Downtime
SCALE 15x Minimizing PostgreSQL Major Version Upgrade DowntimeSCALE 15x Minimizing PostgreSQL Major Version Upgrade Downtime
SCALE 15x Minimizing PostgreSQL Major Version Upgrade DowntimeJeff Frost
 
Как PostgreSQL работает с диском
Как PostgreSQL работает с дискомКак PostgreSQL работает с диском
Как PostgreSQL работает с дискомPostgreSQL-Consulting
 
Nine Circles of Inferno or Explaining the PostgreSQL Vacuum
Nine Circles of Inferno or Explaining the PostgreSQL VacuumNine Circles of Inferno or Explaining the PostgreSQL Vacuum
Nine Circles of Inferno or Explaining the PostgreSQL VacuumAlexey Lesovsky
 
Out of the box replication in postgres 9.4
Out of the box replication in postgres 9.4Out of the box replication in postgres 9.4
Out of the box replication in postgres 9.4Denish Patel
 
PostgreSQL Meetup Berlin at Zalando HQ
PostgreSQL Meetup Berlin at Zalando HQPostgreSQL Meetup Berlin at Zalando HQ
PostgreSQL Meetup Berlin at Zalando HQPostgreSQL-Consulting
 
Postgresql database administration volume 1
Postgresql database administration volume 1Postgresql database administration volume 1
Postgresql database administration volume 1Federico Campoli
 
Streaming replication in practice
Streaming replication in practiceStreaming replication in practice
Streaming replication in practiceAlexey Lesovsky
 
Sessionization with Spark streaming
Sessionization with Spark streamingSessionization with Spark streaming
Sessionization with Spark streamingRamūnas Urbonas
 
GOTO 2013: Why Zalando trusts in PostgreSQL
GOTO 2013: Why Zalando trusts in PostgreSQLGOTO 2013: Why Zalando trusts in PostgreSQL
GOTO 2013: Why Zalando trusts in PostgreSQLHenning Jacobs
 
What’s the Best PostgreSQL High Availability Framework? PAF vs. repmgr vs. Pa...
What’s the Best PostgreSQL High Availability Framework? PAF vs. repmgr vs. Pa...What’s the Best PostgreSQL High Availability Framework? PAF vs. repmgr vs. Pa...
What’s the Best PostgreSQL High Availability Framework? PAF vs. repmgr vs. Pa...ScaleGrid.io
 
Autovacuum, explained for engineers, new improved version PGConf.eu 2015 Vienna
Autovacuum, explained for engineers, new improved version PGConf.eu 2015 ViennaAutovacuum, explained for engineers, new improved version PGConf.eu 2015 Vienna
Autovacuum, explained for engineers, new improved version PGConf.eu 2015 ViennaPostgreSQL-Consulting
 
Peeking into the Black Hole Called PL/PGSQL - the New PL Profiler / Jan Wieck...
Peeking into the Black Hole Called PL/PGSQL - the New PL Profiler / Jan Wieck...Peeking into the Black Hole Called PL/PGSQL - the New PL Profiler / Jan Wieck...
Peeking into the Black Hole Called PL/PGSQL - the New PL Profiler / Jan Wieck...Ontico
 

What's hot (20)

How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015
How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015
How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015
 
PostgreSQL Streaming Replication Cheatsheet
PostgreSQL Streaming Replication CheatsheetPostgreSQL Streaming Replication Cheatsheet
PostgreSQL Streaming Replication Cheatsheet
 
PostgreSQL Replication Tutorial
PostgreSQL Replication TutorialPostgreSQL Replication Tutorial
PostgreSQL Replication Tutorial
 
Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.
 
PostgreSQL Administration for System Administrators
PostgreSQL Administration for System AdministratorsPostgreSQL Administration for System Administrators
PostgreSQL Administration for System Administrators
 
collectd & PostgreSQL
collectd & PostgreSQLcollectd & PostgreSQL
collectd & PostgreSQL
 
SCALE 15x Minimizing PostgreSQL Major Version Upgrade Downtime
SCALE 15x Minimizing PostgreSQL Major Version Upgrade DowntimeSCALE 15x Minimizing PostgreSQL Major Version Upgrade Downtime
SCALE 15x Minimizing PostgreSQL Major Version Upgrade Downtime
 
Как PostgreSQL работает с диском
Как PostgreSQL работает с дискомКак PostgreSQL работает с диском
Как PostgreSQL работает с диском
 
Nine Circles of Inferno or Explaining the PostgreSQL Vacuum
Nine Circles of Inferno or Explaining the PostgreSQL VacuumNine Circles of Inferno or Explaining the PostgreSQL Vacuum
Nine Circles of Inferno or Explaining the PostgreSQL Vacuum
 
Out of the box replication in postgres 9.4
Out of the box replication in postgres 9.4Out of the box replication in postgres 9.4
Out of the box replication in postgres 9.4
 
PostgreSQL Meetup Berlin at Zalando HQ
PostgreSQL Meetup Berlin at Zalando HQPostgreSQL Meetup Berlin at Zalando HQ
PostgreSQL Meetup Berlin at Zalando HQ
 
Postgresql database administration volume 1
Postgresql database administration volume 1Postgresql database administration volume 1
Postgresql database administration volume 1
 
PostgreSQL and RAM usage
PostgreSQL and RAM usagePostgreSQL and RAM usage
PostgreSQL and RAM usage
 
Streaming replication in practice
Streaming replication in practiceStreaming replication in practice
Streaming replication in practice
 
Sessionization with Spark streaming
Sessionization with Spark streamingSessionization with Spark streaming
Sessionization with Spark streaming
 
GOTO 2013: Why Zalando trusts in PostgreSQL
GOTO 2013: Why Zalando trusts in PostgreSQLGOTO 2013: Why Zalando trusts in PostgreSQL
GOTO 2013: Why Zalando trusts in PostgreSQL
 
Strategic autovacuum
Strategic autovacuumStrategic autovacuum
Strategic autovacuum
 
What’s the Best PostgreSQL High Availability Framework? PAF vs. repmgr vs. Pa...
What’s the Best PostgreSQL High Availability Framework? PAF vs. repmgr vs. Pa...What’s the Best PostgreSQL High Availability Framework? PAF vs. repmgr vs. Pa...
What’s the Best PostgreSQL High Availability Framework? PAF vs. repmgr vs. Pa...
 
Autovacuum, explained for engineers, new improved version PGConf.eu 2015 Vienna
Autovacuum, explained for engineers, new improved version PGConf.eu 2015 ViennaAutovacuum, explained for engineers, new improved version PGConf.eu 2015 Vienna
Autovacuum, explained for engineers, new improved version PGConf.eu 2015 Vienna
 
Peeking into the Black Hole Called PL/PGSQL - the New PL Profiler / Jan Wieck...
Peeking into the Black Hole Called PL/PGSQL - the New PL Profiler / Jan Wieck...Peeking into the Black Hole Called PL/PGSQL - the New PL Profiler / Jan Wieck...
Peeking into the Black Hole Called PL/PGSQL - the New PL Profiler / Jan Wieck...
 

Similar to Troubleshooting PostgreSQL with pgCenter

Aplicações 10x a 100x mais rápida com o postgre sql
Aplicações 10x a 100x mais rápida com o postgre sqlAplicações 10x a 100x mais rápida com o postgre sql
Aplicações 10x a 100x mais rápida com o postgre sqlFabio Telles Rodriguez
 
OSDC 2017 - Werner Fischer - Linux performance profiling and monitoring
OSDC 2017 - Werner Fischer - Linux performance profiling and monitoringOSDC 2017 - Werner Fischer - Linux performance profiling and monitoring
OSDC 2017 - Werner Fischer - Linux performance profiling and monitoringNETWAYS
 
YOW2020 Linux Systems Performance
YOW2020 Linux Systems PerformanceYOW2020 Linux Systems Performance
YOW2020 Linux Systems PerformanceBrendan Gregg
 
Linux Systems Performance 2016
Linux Systems Performance 2016Linux Systems Performance 2016
Linux Systems Performance 2016Brendan Gregg
 
Nodejs性能分析优化和分布式设计探讨
Nodejs性能分析优化和分布式设计探讨Nodejs性能分析优化和分布式设计探讨
Nodejs性能分析优化和分布式设计探讨flyinweb
 
OSMC 2015: Linux Performance Profiling and Monitoring by Werner Fischer
OSMC 2015: Linux Performance Profiling and Monitoring by Werner FischerOSMC 2015: Linux Performance Profiling and Monitoring by Werner Fischer
OSMC 2015: Linux Performance Profiling and Monitoring by Werner FischerNETWAYS
 
OSMC 2015 | Linux Performance Profiling and Monitoring by Werner Fischer
OSMC 2015 | Linux Performance Profiling and Monitoring by Werner FischerOSMC 2015 | Linux Performance Profiling and Monitoring by Werner Fischer
OSMC 2015 | Linux Performance Profiling and Monitoring by Werner FischerNETWAYS
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLCommand Prompt., Inc
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLMark Wong
 
Как понять, что происходит на сервере? / Александр Крижановский (NatSys Lab.,...
Как понять, что происходит на сервере? / Александр Крижановский (NatSys Lab.,...Как понять, что происходит на сервере? / Александр Крижановский (NatSys Lab.,...
Как понять, что происходит на сервере? / Александр Крижановский (NatSys Lab.,...Ontico
 
OSDC 2015: Georg Schönberger | Linux Performance Profiling and Monitoring
OSDC 2015: Georg Schönberger | Linux Performance Profiling and MonitoringOSDC 2015: Georg Schönberger | Linux Performance Profiling and Monitoring
OSDC 2015: Georg Schönberger | Linux Performance Profiling and MonitoringNETWAYS
 
Linux Performance Profiling and Monitoring
Linux Performance Profiling and MonitoringLinux Performance Profiling and Monitoring
Linux Performance Profiling and MonitoringGeorg Schönberger
 
LISA2019 Linux Systems Performance
LISA2019 Linux Systems PerformanceLISA2019 Linux Systems Performance
LISA2019 Linux Systems PerformanceBrendan Gregg
 
Es werde Licht! Monitoring jenseits von tail und grep
Es werde Licht! Monitoring jenseits von tail und grepEs werde Licht! Monitoring jenseits von tail und grep
Es werde Licht! Monitoring jenseits von tail und grepOliver Fischer
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLCommand Prompt., Inc
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLMark Wong
 

Similar to Troubleshooting PostgreSQL with pgCenter (20)

Aplicações 10x a 100x mais rápida com o postgre sql
Aplicações 10x a 100x mais rápida com o postgre sqlAplicações 10x a 100x mais rápida com o postgre sql
Aplicações 10x a 100x mais rápida com o postgre sql
 
OSDC 2017 - Werner Fischer - Linux performance profiling and monitoring
OSDC 2017 - Werner Fischer - Linux performance profiling and monitoringOSDC 2017 - Werner Fischer - Linux performance profiling and monitoring
OSDC 2017 - Werner Fischer - Linux performance profiling and monitoring
 
YOW2020 Linux Systems Performance
YOW2020 Linux Systems PerformanceYOW2020 Linux Systems Performance
YOW2020 Linux Systems Performance
 
Linux Systems Performance 2016
Linux Systems Performance 2016Linux Systems Performance 2016
Linux Systems Performance 2016
 
Nodejs性能分析优化和分布式设计探讨
Nodejs性能分析优化和分布式设计探讨Nodejs性能分析优化和分布式设计探讨
Nodejs性能分析优化和分布式设计探讨
 
Explain this!
Explain this!Explain this!
Explain this!
 
Osol Pgsql
Osol PgsqlOsol Pgsql
Osol Pgsql
 
OSMC 2015: Linux Performance Profiling and Monitoring by Werner Fischer
OSMC 2015: Linux Performance Profiling and Monitoring by Werner FischerOSMC 2015: Linux Performance Profiling and Monitoring by Werner Fischer
OSMC 2015: Linux Performance Profiling and Monitoring by Werner Fischer
 
OSMC 2015 | Linux Performance Profiling and Monitoring by Werner Fischer
OSMC 2015 | Linux Performance Profiling and Monitoring by Werner FischerOSMC 2015 | Linux Performance Profiling and Monitoring by Werner Fischer
OSMC 2015 | Linux Performance Profiling and Monitoring by Werner Fischer
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQL
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQL
 
Как понять, что происходит на сервере? / Александр Крижановский (NatSys Lab.,...
Как понять, что происходит на сервере? / Александр Крижановский (NatSys Lab.,...Как понять, что происходит на сервере? / Александр Крижановский (NatSys Lab.,...
Как понять, что происходит на сервере? / Александр Крижановский (NatSys Lab.,...
 
OSDC 2015: Georg Schönberger | Linux Performance Profiling and Monitoring
OSDC 2015: Georg Schönberger | Linux Performance Profiling and MonitoringOSDC 2015: Georg Schönberger | Linux Performance Profiling and Monitoring
OSDC 2015: Georg Schönberger | Linux Performance Profiling and Monitoring
 
Linux Performance Profiling and Monitoring
Linux Performance Profiling and MonitoringLinux Performance Profiling and Monitoring
Linux Performance Profiling and Monitoring
 
test
testtest
test
 
LISA2019 Linux Systems Performance
LISA2019 Linux Systems PerformanceLISA2019 Linux Systems Performance
LISA2019 Linux Systems Performance
 
sun solaris
sun solarissun solaris
sun solaris
 
Es werde Licht! Monitoring jenseits von tail und grep
Es werde Licht! Monitoring jenseits von tail und grepEs werde Licht! Monitoring jenseits von tail und grep
Es werde Licht! Monitoring jenseits von tail und grep
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQL
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQL
 

More from Alexey Lesovsky

Отладка и устранение проблем в PostgreSQL Streaming Replication.
Отладка и устранение проблем в PostgreSQL Streaming Replication.Отладка и устранение проблем в PostgreSQL Streaming Replication.
Отладка и устранение проблем в PostgreSQL Streaming Replication.Alexey Lesovsky
 
Call of Postgres: Advanced Operations (part 5)
Call of Postgres: Advanced Operations (part 5)Call of Postgres: Advanced Operations (part 5)
Call of Postgres: Advanced Operations (part 5)Alexey Lesovsky
 
Call of Postgres: Advanced Operations (part 4)
Call of Postgres: Advanced Operations (part 4)Call of Postgres: Advanced Operations (part 4)
Call of Postgres: Advanced Operations (part 4)Alexey Lesovsky
 
Call of Postgres: Advanced Operations (part 3)
Call of Postgres: Advanced Operations (part 3)Call of Postgres: Advanced Operations (part 3)
Call of Postgres: Advanced Operations (part 3)Alexey Lesovsky
 
Call of Postgres: Advanced Operations (part 2)
Call of Postgres: Advanced Operations (part 2)Call of Postgres: Advanced Operations (part 2)
Call of Postgres: Advanced Operations (part 2)Alexey Lesovsky
 
Call of Postgres: Advanced Operations (part 1)
Call of Postgres: Advanced Operations (part 1)Call of Postgres: Advanced Operations (part 1)
Call of Postgres: Advanced Operations (part 1)Alexey Lesovsky
 
PostgreSQL Streaming Replication
PostgreSQL Streaming ReplicationPostgreSQL Streaming Replication
PostgreSQL Streaming ReplicationAlexey Lesovsky
 
PostgreSQL Vacuum: Nine Circles of Hell
PostgreSQL Vacuum: Nine Circles of HellPostgreSQL Vacuum: Nine Circles of Hell
PostgreSQL Vacuum: Nine Circles of HellAlexey Lesovsky
 
Tuning Linux for Databases.
Tuning Linux for Databases.Tuning Linux for Databases.
Tuning Linux for Databases.Alexey Lesovsky
 
Streaming replication in practice
Streaming replication in practiceStreaming replication in practice
Streaming replication in practiceAlexey Lesovsky
 
Highload 2014. PostgreSQL: ups, DevOps.
Highload 2014. PostgreSQL: ups, DevOps.Highload 2014. PostgreSQL: ups, DevOps.
Highload 2014. PostgreSQL: ups, DevOps.Alexey Lesovsky
 
Linux tuning for PostgreSQL at Secon 2015
Linux tuning for PostgreSQL at Secon 2015Linux tuning for PostgreSQL at Secon 2015
Linux tuning for PostgreSQL at Secon 2015Alexey Lesovsky
 

More from Alexey Lesovsky (12)

Отладка и устранение проблем в PostgreSQL Streaming Replication.
Отладка и устранение проблем в PostgreSQL Streaming Replication.Отладка и устранение проблем в PostgreSQL Streaming Replication.
Отладка и устранение проблем в PostgreSQL Streaming Replication.
 
Call of Postgres: Advanced Operations (part 5)
Call of Postgres: Advanced Operations (part 5)Call of Postgres: Advanced Operations (part 5)
Call of Postgres: Advanced Operations (part 5)
 
Call of Postgres: Advanced Operations (part 4)
Call of Postgres: Advanced Operations (part 4)Call of Postgres: Advanced Operations (part 4)
Call of Postgres: Advanced Operations (part 4)
 
Call of Postgres: Advanced Operations (part 3)
Call of Postgres: Advanced Operations (part 3)Call of Postgres: Advanced Operations (part 3)
Call of Postgres: Advanced Operations (part 3)
 
Call of Postgres: Advanced Operations (part 2)
Call of Postgres: Advanced Operations (part 2)Call of Postgres: Advanced Operations (part 2)
Call of Postgres: Advanced Operations (part 2)
 
Call of Postgres: Advanced Operations (part 1)
Call of Postgres: Advanced Operations (part 1)Call of Postgres: Advanced Operations (part 1)
Call of Postgres: Advanced Operations (part 1)
 
PostgreSQL Streaming Replication
PostgreSQL Streaming ReplicationPostgreSQL Streaming Replication
PostgreSQL Streaming Replication
 
PostgreSQL Vacuum: Nine Circles of Hell
PostgreSQL Vacuum: Nine Circles of HellPostgreSQL Vacuum: Nine Circles of Hell
PostgreSQL Vacuum: Nine Circles of Hell
 
Tuning Linux for Databases.
Tuning Linux for Databases.Tuning Linux for Databases.
Tuning Linux for Databases.
 
Streaming replication in practice
Streaming replication in practiceStreaming replication in practice
Streaming replication in practice
 
Highload 2014. PostgreSQL: ups, DevOps.
Highload 2014. PostgreSQL: ups, DevOps.Highload 2014. PostgreSQL: ups, DevOps.
Highload 2014. PostgreSQL: ups, DevOps.
 
Linux tuning for PostgreSQL at Secon 2015
Linux tuning for PostgreSQL at Secon 2015Linux tuning for PostgreSQL at Secon 2015
Linux tuning for PostgreSQL at Secon 2015
 

Recently uploaded

BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 

Recently uploaded (20)

BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 

Troubleshooting PostgreSQL with pgCenter

  • 1. Troubleshooting PostgreSQL with pgCenter Alexey Lesovsky alexey.lesovsky@dataegret.com
  • 2. dataegret.com Introduction • What is pgCenter. • Goals and quick overview. Troubleshooting cases • Health checks and load spikes. • Hidden problems. • Client's activity. • Streaming replication. 02 01
  • 4. • PgCenter overview. • How to use pgCenter. • How to troubleshoot PostgreSQL with pgCenter. Goals01 dataegret.com
  • 5. • Top-like admin tool for Postgres stats. • Quick Postgres administration. • Available on RHEL/CentOS/Fedora/ALT Linux/Ubuntu... • Hosted on GitHub. • Work in progress. What is pgCenter01 dataegret.com
  • 7. • PostgreSQL 9.x support. • Support of the most stats views. • Support of the system stats. • PostgreSQL admin tasks: configs, logs, reload, cancel/kill backends. Features01 dataegret.com
  • 8. Interface overview01 dataegret.com pgcenter: 2017-04-05 17:40:28, load average: 1.59, 0.74, 0.42 conn1 [ok]: /run/postgresql:5433 postgres@postg (ver: 10devel, up 2 days 20:29:27) %cpu: 14.3 us, 3.9 sy, 0.0 ni, 45.8 id, 36.0 wa, 0.0 hi, 0.0 si, 0.0 st activity: 8/100 conns, 0/0 prepared, 1 idle, 0 idle_xact, 2 active, 6 waiting, 0 others MiB mem: 7836 total, 1582 free, 3910 used, 2344 buff/cached autovacuum: 0/3 workers/max, 0 manual, 0 wraparound, 00:00:00 vac_maxtime MiB swap: 5119 total, 5088 free, 31 used, 26/0 dirty/writeback statements: 7050 stmt/s, 0.123 stmt_avgtime, 00:00:00 xact_maxtime, 00:00:00 prep_maxtime user database t_all_t t_read_t t_write_t t_cpu_t all_t read_t write_t cpu_t calls queryid query postgres pgbench 00:05:31 00:00:00 00:00:00 00:05:31 510 0 0 510 1006 08393211ce UPDATE pgbench_accounts SET abalance = abalance + $N WHERE aid = $N postgres pgbench 00:00:09 00:00:00 00:00:00 00:00:09 14 0 0 14 1005 7c5345de88 UPDATE pgbench_branches SET bbalance = bbalance + $N WHERE bid = $N postgres pgbench 00:00:07 00:00:00 00:00:00 00:00:07 14 0 0 14 1005 2cdaf0baaf UPDATE pgbench_tellers SET tbalance = tbalance + $N WHERE tid = $N postgres pgbench 00:00:04 00:00:00 00:00:00 00:00:04 10 0 0 10 1005 5f72672d89 SELECT abalance FROM pgbench_accounts WHERE aid = $N postgres pgbench 00:00:04 00:00:00 00:00:00 00:00:04 0 0 0 0 0 1097fe4e1b copy pgbench_accounts from stdin postgres pgbench 00:00:03 00:00:00 00:00:00 00:00:03 0 0 0 0 0 3065f1faff SELECT datname, xact_commit AS commit, xact_rollback AS rollback, b postgres pgbench 00:00:02 00:00:00 00:00:00 00:00:02 7 0 0 7 1005 f1f154154f INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES ($ postgres postgres 00:00:02 00:00:00 00:00:00 00:00:02 9 0 0 9 1 9f21a96353 SELECT a.rolname AS user, d.datname AS database, date_trunc($N, rou postgres postgres 00:00:01 00:00:00 00:00:00 00:00:01 0 0 0 0 0 b0cfaf67a8 create database pgbench postgres postgres 00:00:01 00:00:00 00:00:00 00:00:01 0 0 0 0 0 6441d14dc3 SELECT datname, xact_commit AS commit, xact_rollback AS rollback, b Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await r_await w_await %util sda: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 sda1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 sda2: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 sdb: 0.00 6.86 0.00 288.24 0.00 2.69 19.13 0.82 2.82 0.00 2.82 82.06 sdb1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 sdb2: 0.00 6.86 0.00 284.31 0.00 2.69 19.39 0.11 0.39 0.00 0.39 10.98 dm-0: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 dm-1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 dm-2: 0.00 0.00 0.00 293.14 0.00 2.68 18.70 1.66 5.62 0.00 5.62 82.16
  • 9. Interface overview01 dataegret.com pgcenter: 2017-04-05 17:40:28, load average: 1.59, 0.74, 0.42 conn1 [ok]: /run/postgresql:5433 postgres@postg (ver: 10devel, up 2 days 20:29:27) %cpu: 14.3 us, 3.9 sy, 0.0 ni, 45.8 id, 36.0 wa, 0.0 hi, 0.0 si, 0.0 st activity: 8/100 conns, 0/0 prepared, 1 idle, 0 idle_xact, 2 active, 6 waiting, 0 others MiB mem: 7836 total, 1582 free, 3910 used, 2344 buff/cached autovacuum: 0/3 workers/max, 0 manual, 0 wraparound, 00:00:00 vac_maxtime MiB swap: 5119 total, 5088 free, 31 used, 26/0 dirty/writeback statements: 7050 stmt/s, 0.123 stmt_avgtime, 00:00:00 xact_maxtime, 00:00:00 prep_maxtime user database t_all_t t_read_t t_write_t t_cpu_t all_t read_t write_t cpu_t calls queryid query postgres pgbench 00:05:31 00:00:00 00:00:00 00:05:31 510 0 0 510 1006 08393211ce UPDATE pgbench_accounts SET abalance = abalance + $N WHERE aid = $N postgres pgbench 00:00:09 00:00:00 00:00:00 00:00:09 14 0 0 14 1005 7c5345de88 UPDATE pgbench_branches SET bbalance = bbalance + $N WHERE bid = $N postgres pgbench 00:00:07 00:00:00 00:00:00 00:00:07 14 0 0 14 1005 2cdaf0baaf UPDATE pgbench_tellers SET tbalance = tbalance + $N WHERE tid = $N postgres pgbench 00:00:04 00:00:00 00:00:00 00:00:04 10 0 0 10 1005 5f72672d89 SELECT abalance FROM pgbench_accounts WHERE aid = $N postgres pgbench 00:00:04 00:00:00 00:00:00 00:00:04 0 0 0 0 0 1097fe4e1b copy pgbench_accounts from stdin postgres pgbench 00:00:03 00:00:00 00:00:00 00:00:03 0 0 0 0 0 3065f1faff SELECT datname, xact_commit AS commit, xact_rollback AS rollback, b postgres pgbench 00:00:02 00:00:00 00:00:00 00:00:02 7 0 0 7 1005 f1f154154f INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES ($ postgres postgres 00:00:02 00:00:00 00:00:00 00:00:02 9 0 0 9 1 9f21a96353 SELECT a.rolname AS user, d.datname AS database, date_trunc($N, rou postgres postgres 00:00:01 00:00:00 00:00:00 00:00:01 0 0 0 0 0 b0cfaf67a8 create database pgbench postgres postgres 00:00:01 00:00:00 00:00:00 00:00:01 0 0 0 0 0 6441d14dc3 SELECT datname, xact_commit AS commit, xact_rollback AS rollback, b Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await r_await w_await %util sda: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 sda1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 sda2: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 sdb: 0.00 6.86 0.00 288.24 0.00 2.69 19.13 0.82 2.82 0.00 2.82 82.06 sdb1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 sdb2: 0.00 6.86 0.00 284.31 0.00 2.69 19.39 0.11 0.39 0.00 0.39 10.98 dm-0: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 dm-1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 dm-2: 0.00 0.00 0.00 293.14 0.00 2.68 18.70 1.66 5.62 0.00 5.62 82.16
  • 10. Interface overview01 dataegret.com pgcenter: 2017-04-05 17:40:28, load average: 1.59, 0.74, 0.42 conn1 [ok]: /run/postgresql:5433 postgres@postg (ver: 10devel, up 2 days 20:29:27) %cpu: 14.3 us, 3.9 sy, 0.0 ni, 45.8 id, 36.0 wa, 0.0 hi, 0.0 si, 0.0 st activity: 8/100 conns, 0/0 prepared, 1 idle, 0 idle_xact, 2 active, 6 waiting, 0 others MiB mem: 7836 total, 1582 free, 3910 used, 2344 buff/cached autovacuum: 0/3 workers/max, 0 manual, 0 wraparound, 00:00:00 vac_maxtime MiB swap: 5119 total, 5088 free, 31 used, 26/0 dirty/writeback statements: 7050 stmt/s, 0.123 stmt_avgtime, 00:00:00 xact_maxtime, 00:00:00 prep_maxtime user database t_all_t t_read_t t_write_t t_cpu_t all_t read_t write_t cpu_t calls queryid query postgres pgbench 00:05:31 00:00:00 00:00:00 00:05:31 510 0 0 510 1006 08393211ce UPDATE pgbench_accounts SET abalance = abalance + $N WHERE aid = $N postgres pgbench 00:00:09 00:00:00 00:00:00 00:00:09 14 0 0 14 1005 7c5345de88 UPDATE pgbench_branches SET bbalance = bbalance + $N WHERE bid = $N postgres pgbench 00:00:07 00:00:00 00:00:00 00:00:07 14 0 0 14 1005 2cdaf0baaf UPDATE pgbench_tellers SET tbalance = tbalance + $N WHERE tid = $N postgres pgbench 00:00:04 00:00:00 00:00:00 00:00:04 10 0 0 10 1005 5f72672d89 SELECT abalance FROM pgbench_accounts WHERE aid = $N postgres pgbench 00:00:04 00:00:00 00:00:00 00:00:04 0 0 0 0 0 1097fe4e1b copy pgbench_accounts from stdin postgres pgbench 00:00:03 00:00:00 00:00:00 00:00:03 0 0 0 0 0 3065f1faff SELECT datname, xact_commit AS commit, xact_rollback AS rollback, b postgres pgbench 00:00:02 00:00:00 00:00:00 00:00:02 7 0 0 7 1005 f1f154154f INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES ($ postgres postgres 00:00:02 00:00:00 00:00:00 00:00:02 9 0 0 9 1 9f21a96353 SELECT a.rolname AS user, d.datname AS database, date_trunc($N, rou postgres postgres 00:00:01 00:00:00 00:00:00 00:00:01 0 0 0 0 0 b0cfaf67a8 create database pgbench postgres postgres 00:00:01 00:00:00 00:00:00 00:00:01 0 0 0 0 0 6441d14dc3 SELECT datname, xact_commit AS commit, xact_rollback AS rollback, b Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await r_await w_await %util sda: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 sda1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 sda2: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 sdb: 0.00 6.86 0.00 288.24 0.00 2.69 19.13 0.82 2.82 0.00 2.82 82.06 sdb1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 sdb2: 0.00 6.86 0.00 284.31 0.00 2.69 19.39 0.11 0.39 0.00 0.39 10.98 dm-0: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 dm-1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 dm-2: 0.00 0.00 0.00 293.14 0.00 2.68 18.70 1.66 5.62 0.00 5.62 82.16
  • 11. Interface overview01 dataegret.com pgcenter: 2017-04-05 17:40:28, load average: 1.59, 0.74, 0.42 conn1 [ok]: /run/postgresql:5433 postgres@postg (ver: 10devel, up 2 days 20:29:27) %cpu: 14.3 us, 3.9 sy, 0.0 ni, 45.8 id, 36.0 wa, 0.0 hi, 0.0 si, 0.0 st activity: 8/100 conns, 0/0 prepared, 1 idle, 0 idle_xact, 2 active, 6 waiting, 0 others MiB mem: 7836 total, 1582 free, 3910 used, 2344 buff/cached autovacuum: 0/3 workers/max, 0 manual, 0 wraparound, 00:00:00 vac_maxtime MiB swap: 5119 total, 5088 free, 31 used, 26/0 dirty/writeback statements: 7050 stmt/s, 0.123 stmt_avgtime, 00:00:00 xact_maxtime, 00:00:00 prep_maxtime user database t_all_t t_read_t t_write_t t_cpu_t all_t read_t write_t cpu_t calls queryid query postgres pgbench 00:05:31 00:00:00 00:00:00 00:05:31 510 0 0 510 1006 08393211ce UPDATE pgbench_accounts SET abalance = abalance + $N WHERE aid = $N postgres pgbench 00:00:09 00:00:00 00:00:00 00:00:09 14 0 0 14 1005 7c5345de88 UPDATE pgbench_branches SET bbalance = bbalance + $N WHERE bid = $N postgres pgbench 00:00:07 00:00:00 00:00:00 00:00:07 14 0 0 14 1005 2cdaf0baaf UPDATE pgbench_tellers SET tbalance = tbalance + $N WHERE tid = $N postgres pgbench 00:00:04 00:00:00 00:00:00 00:00:04 10 0 0 10 1005 5f72672d89 SELECT abalance FROM pgbench_accounts WHERE aid = $N postgres pgbench 00:00:04 00:00:00 00:00:00 00:00:04 0 0 0 0 0 1097fe4e1b copy pgbench_accounts from stdin postgres pgbench 00:00:03 00:00:00 00:00:00 00:00:03 0 0 0 0 0 3065f1faff SELECT datname, xact_commit AS commit, xact_rollback AS rollback, b postgres pgbench 00:00:02 00:00:00 00:00:00 00:00:02 7 0 0 7 1005 f1f154154f INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES ($ postgres postgres 00:00:02 00:00:00 00:00:00 00:00:02 9 0 0 9 1 9f21a96353 SELECT a.rolname AS user, d.datname AS database, date_trunc($N, rou postgres postgres 00:00:01 00:00:00 00:00:00 00:00:01 0 0 0 0 0 b0cfaf67a8 create database pgbench postgres postgres 00:00:01 00:00:00 00:00:00 00:00:01 0 0 0 0 0 6441d14dc3 SELECT datname, xact_commit AS commit, xact_rollback AS rollback, b Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await r_await w_await %util sda: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 sda1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 sda2: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 sdb: 0.00 6.86 0.00 288.24 0.00 2.69 19.13 0.82 2.82 0.00 2.82 82.06 sdb1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 sdb2: 0.00 6.86 0.00 284.31 0.00 2.69 19.39 0.11 0.39 0.00 0.39 10.98 dm-0: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 dm-1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 dm-2: 0.00 0.00 0.00 293.14 0.00 2.68 18.70 1.66 5.62 0.00 5.62 82.16
  • 12. Interface overview01 dataegret.com pgcenter: 2017-04-05 17:40:28, load average: 1.59, 0.74, 0.42 conn1 [ok]: /run/postgresql:5433 postgres@postg (ver: 10devel, up 2 days 20:29:27) %cpu: 14.3 us, 3.9 sy, 0.0 ni, 45.8 id, 36.0 wa, 0.0 hi, 0.0 si, 0.0 st activity: 8/100 conns, 0/0 prepared, 1 idle, 0 idle_xact, 2 active, 6 waiting, 0 others MiB mem: 7836 total, 1582 free, 3910 used, 2344 buff/cached autovacuum: 0/3 workers/max, 0 manual, 0 wraparound, 00:00:00 vac_maxtime MiB swap: 5119 total, 5088 free, 31 used, 26/0 dirty/writeback statements: 7050 stmt/s, 0.123 stmt_avgtime, 00:00:00 xact_maxtime, 00:00:00 prep_maxtime user database t_all_t t_read_t t_write_t t_cpu_t all_t read_t write_t cpu_t calls queryid query postgres pgbench 00:05:31 00:00:00 00:00:00 00:05:31 510 0 0 510 1006 08393211ce UPDATE pgbench_accounts SET abalance = abalance + $N WHERE aid = $N postgres pgbench 00:00:09 00:00:00 00:00:00 00:00:09 14 0 0 14 1005 7c5345de88 UPDATE pgbench_branches SET bbalance = bbalance + $N WHERE bid = $N postgres pgbench 00:00:07 00:00:00 00:00:00 00:00:07 14 0 0 14 1005 2cdaf0baaf UPDATE pgbench_tellers SET tbalance = tbalance + $N WHERE tid = $N postgres pgbench 00:00:04 00:00:00 00:00:00 00:00:04 10 0 0 10 1005 5f72672d89 SELECT abalance FROM pgbench_accounts WHERE aid = $N postgres pgbench 00:00:04 00:00:00 00:00:00 00:00:04 0 0 0 0 0 1097fe4e1b copy pgbench_accounts from stdin postgres pgbench 00:00:03 00:00:00 00:00:00 00:00:03 0 0 0 0 0 3065f1faff SELECT datname, xact_commit AS commit, xact_rollback AS rollback, b postgres pgbench 00:00:02 00:00:00 00:00:00 00:00:02 7 0 0 7 1005 f1f154154f INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES ($ postgres postgres 00:00:02 00:00:00 00:00:00 00:00:02 9 0 0 9 1 9f21a96353 SELECT a.rolname AS user, d.datname AS database, date_trunc($N, rou postgres postgres 00:00:01 00:00:00 00:00:00 00:00:01 0 0 0 0 0 b0cfaf67a8 create database pgbench postgres postgres 00:00:01 00:00:00 00:00:00 00:00:01 0 0 0 0 0 6441d14dc3 SELECT datname, xact_commit AS commit, xact_rollback AS rollback, b Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await r_await w_await %util sda: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 sda1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 sda2: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 sdb: 0.00 6.86 0.00 288.24 0.00 2.69 19.13 0.82 2.82 0.00 2.82 82.06 sdb1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 sdb2: 0.00 6.86 0.00 284.31 0.00 2.69 19.39 0.11 0.39 0.00 0.39 10.98 dm-0: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 dm-1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 dm-2: 0.00 0.00 0.00 293.14 0.00 2.68 18.70 1.66 5.62 0.00 5.62 82.16
  • 14. • Iostat – storage devices stats. • Nicstat – network interfaces stats. • Log tail – latest lines from postgres logs. Additional stats01 dataegret.com
  • 16. • Health checks and load spikes. • Hidden problems. • Clients' activity. • Streaming replication. Troubleshooting cases02 dataegret.com
  • 17. Check whether is everything OK? or When something really goes wrong. Health checks or load spikes02 dataegret.com
  • 18. Run pgCenter. Check system resources (cpu, memory/swap, storage, network). Check postgres activity (conn's states, xact age). Check iostat/nicstat if required. Health checks and load spikes02 dataegret.com
  • 19. Health checks and load spikes02 dataegret.com pgcenter: 2017-04-07 21:50:36, load average: 4.14, 0.98, 0.46 conn1 [ok]: /var/run/postgresql:5432 postgres@p (ver: 9.6.2, up 1 day 04:02:57) %cpu: 2.9 us, 0.7 sy, 0.0 ni, 11.4 id, 85.0 wa, 0.0 hi, 0.0 si, 0.0 st activity: 13/100 conns, 0/0 prepared, 0 idle, 0 idle_xact, 13 active, 0 waiting, 0 others MiB mem: 32124 total, 6228 free, 25464 used, 432 buff/cached autovacuum: 0/3 workers/max, 0 manual, 0 wraparound, 00:00:00 vac_maxtime MiB swap: 15257 total, 15257 free, 0 used, 1/0 dirty/writeback statements: 3519 stmt/s, 0.263 stmt_avgtime, 00:00:00 xact_maxtime, 00:00:00 prep_maxtime datname commit rollback reads hits returned fetched inserts updates deletes conflicts deadlocks tmp_files tmp_bytes read_t write_t pgbench_64gb 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 pgbench_6gb 2 0 0 69 999 11 0 0 0 0 0 0 0 0 0 postgres 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 template0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await r_await w_await %util sda: 0.00 3.92 841.18 20.59 6.57 3.75 24.52 11.63 13.44 13.77 0.19 99.22 sda1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 sda2: 0.00 3.92 841.18 20.59 6.57 3.75 24.52 11.59 13.44 13.77 0.19 99.22 sdb: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 sdb1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
  • 20. Health checks and load spikes02 dataegret.com pgcenter: 2017-04-07 21:50:36, load average: 4.14, 0.98, 0.46 conn1 %cpu: 2.9 us, 0.7 sy, 0.0 ni, 11.4 id, 85.0 wa, 0.0 hi, 0.0 si, 0.0 st act MiB mem: 32124 total, 6228 free, 25464 used, 432 buff/cached autov MiB swap: 15257 total, 15257 free, 0 used, 1/0 dirty/writeback state datname commit rollback reads hits returned fetched inserts updates delete pgbench_64gb 0 0 0 0 0 0 0 0 0 pgbench_6gb 2 0 0 69 999 11 0 0 0 postgres 6 0 0 0 0 0 0 0 0 template0 0 0 0 0 0 0 0 0 0
  • 21. Health checks and load spikes02 dataegret.com conn1 [ok]: /var/run/postgresql:5432 postgres@p (ver: 9.6.2, up 1 day 04:02:57) activity: 13/100 conns, 0/0 prepared, 0 idle, 0 idle_xact, 13 active, 0 waiting, 0 others autovacuum: 0/3 workers/max, 0 manual, 0 wraparound, 00:00:00 vac_maxtime statements: 3519 stmt/s, 0.263 stmt_avgtime, 00:00:00 xact_maxtime, 00:00:00 prep_maxtime s deletes conflicts deadlocks tmp_files tmp_bytes read_t write_t 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  • 22. Health checks and load spikes02 dataegret.com Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await r_await w_await %util sda: 0.00 3.92 841.18 20.59 6.57 3.75 24.52 11.63 13.44 13.77 0.19 99.22 sda1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 sda2: 0.00 3.92 841.18 20.59 6.57 3.75 24.52 11.59 13.44 13.77 0.19 99.22 sdb: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 sdb1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
  • 23. Which queries cause the load? Go into details02 dataegret.com
  • 24. pg_stat_statements is a contrib module. GUCs: shared_preload_libraries = 'pg_stat_statements' track_io_timing = on Available stats in pgCenter: timings - how long queries have run; general - number of calls and rows; IO - buffers, temp, local IO. pg_stat_statements02 dataegret.com
  • 25. Health checks and load spikes02 dataegret.com pgcenter: 2017-04-07 21:50:36, load average: 4.14, 0.98, 0.46 conn1 [ok]: /var/run/postgresql:5432 postgres@p (ver: 9.6.2, up 1 day 04:02:57) %cpu: 2.9 us, 0.7 sy, 0.0 ni, 11.4 id, 85.0 wa, 0.0 hi, 0.0 si, 0.0 st activity: 13/100 conns, 0/0 prepared, 0 idle, 0 idle_xact, 13 active, 0 waiting, 0 others MiB mem: 32124 total, 6228 free, 25464 used, 432 buff/cached autovacuum: 0/3 workers/max, 0 manual, 0 wraparound, 00:00:00 vac_maxtime MiB swap: 15257 total, 15257 free, 0 used, 1/0 dirty/writeback statements: 3519 stmt/s, 0.263 stmt_avgtime, 00:00:00 xact_maxtime, 00:00:00 prep_maxtime user database t_all_t t_read_t t_write_t t_cpu_t all_t read_t write_t cpu_t calls queryid query postgres pgbench_64gb 47:38:04 47:33:07 00:00:00 00:04:57 7868 7855 0 12 405 94ffafcb30 UPDATE pgbench_accounts SET abalance = abalance + ? WHERE aid = postgres pgbench_64gb 23:51:51 23:48:08 00:00:00 00:03:42 5 0 0 6 405 111df3ad65 SELECT abalance FROM pgbench_accounts WHERE aid = ?; postgres pgbench_6gb 02:14:23 00:02:45 00:00:00 02:11:38 0 0 0 0 0 e8e1cdb2da SELECT abalance FROM pgbench_accounts WHERE aid = 7287471; postgres pgbench_64gb 00:01:31 00:00:18 00:00:00 00:01:13 6 0 0 6 405 45b6b13d62 UPDATE pgbench_tellers SET tbalance = tbalance + ? WHERE tid = ? postgres pgbench_6gb 01:07:36 00:00:16 00:00:00 01:07:19 0 0 0 0 0 192353e099 UPDATE pgbench_accounts SET abalance = abalance + ? WHERE aid = postgres pgbench_64gb 00:01:22 00:00:08 00:00:00 00:01:13 6 0 0 6 405 e192b43faf UPDATE pgbench_branches SET bbalance = bbalance + ? WHERE bid = okagent pgbench_6gb 00:00:00 00:00:00 00:00:00 00:00:00 0 0 0 0 0 f67e66660a select * from pg_stat_user_tables s limit ? postgres pgbench_6gb 00:00:00 00:00:00 00:00:00 00:00:00 0 0 0 0 0 f6241e76ed vacuum pgbench_branches postgres pgbench_64gb 00:00:00 00:00:00 00:00:00 00:00:00 0 0 0 0 0 eaf8d3d459 truncate pgbench_history postgres pgbench_64gb 00:00:42 00:00:00 00:00:00 00:00:42 4 0 0 3 405 e7cc060768 INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES postgres pgbench_6gb 00:30:17 00:00:00 00:00:00 00:30:17 0 0 0 0 0 e7766dd7c6 UPDATE pgbench_branches SET bbalance = bbalance + ? WHERE bid = okagent pgbench_64gb 00:00:02 00:00:00 00:00:00 00:00:02 0 0 0 0 0 de77700d35 SELECT schemaname, relname, indexrelname, coalesce(pg_relation_ okagent pgbench_64gb 00:00:02 00:00:00 00:00:00 00:00:02 0 0 0 0 0 d1bcc9180b SELECT schemaname, relname, coalesce(heap_blks_read,?) as heap_ postgres pgbench_64gb 00:00:00 00:00:00 00:00:00 00:00:00 0 0 0 0 0 d101ae1052 vacuum pgbench_branches
  • 26. Health checks and load spikes02 dataegret.com oad average: 4.14, 0.98, 0.46 conn1 [ok]: /var/run/postgresql:5432 postgres@p (ver: 9.6.2, up 1 day 04:02:57) ni, 11.4 id, 85.0 wa, 0.0 hi, 0.0 si, 0.0 st activity: 13/100 conns, 0/0 prepared, 0 idle, 0 idle_xact, 13 active, 0 waiting, 0 others ree, 25464 used, 432 buff/cached autovacuum: 0/3 workers/max, 0 manual, 0 wraparound, 00:00:00 vac_maxtime ree, 0 used, 1/0 dirty/writeback statements: 3519 stmt/s, 0.263 stmt_avgtime, 00:00:00 xact_maxtime, 00:00:00 prep_maxtime t_read_t t_write_t t_cpu_t all_t read_t write_t cpu_t calls queryid query 47:33:07 00:00:00 00:04:57 7868 7855 0 12 405 94ffafcb30 UPDATE pgbench_accounts SET abalance = abalance + ? WHERE aid = 23:48:08 00:00:00 00:03:42 5 0 0 6 405 111df3ad65 SELECT abalance FROM pgbench_accounts WHERE aid = ?; 00:02:45 00:00:00 02:11:38 0 0 0 0 0 e8e1cdb2da SELECT abalance FROM pgbench_accounts WHERE aid = 7287471; 00:00:18 00:00:00 00:01:13 6 0 0 6 405 45b6b13d62 UPDATE pgbench_tellers SET tbalance = tbalance + ? WHERE tid = ? 00:00:16 00:00:00 01:07:19 0 0 0 0 0 192353e099 UPDATE pgbench_accounts SET abalance = abalance + ? WHERE aid = 00:00:08 00:00:00 00:01:13 6 0 0 6 405 e192b43faf UPDATE pgbench_branches SET bbalance = bbalance + ? WHERE bid = 00:00:00 00:00:00 00:00:00 0 0 0 0 0 f67e66660a select * from pg_stat_user_tables s limit ? 00:00:00 00:00:00 00:00:00 0 0 0 0 0 f6241e76ed vacuum pgbench_branches 00:00:00 00:00:00 00:00:00 0 0 0 0 0 eaf8d3d459 truncate pgbench_history 00:00:00 00:00:00 00:00:42 4 0 0 3 405 e7cc060768 INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES 00:00:00 00:00:00 00:30:17 0 0 0 0 0 e7766dd7c6 UPDATE pgbench_branches SET bbalance = bbalance + ? WHERE bid = 00:00:00 00:00:00 00:00:02 0 0 0 0 0 de77700d35 SELECT schemaname, relname, indexrelname, coalesce(pg_relation_ 00:00:00 00:00:00 00:00:02 0 0 0 0 0 d1bcc9180b SELECT schemaname, relname, coalesce(heap_blks_read,?) as heap_ 00:00:00 00:00:00 00:00:00 0 0 0 0 0 d101ae1052 vacuum pgbench_branches
  • 27. Another example. Health checks and load spikes02 dataegret.com
  • 28. Health checks and load spikes02 dataegret.com pgcenter: 2017-04-07 21:52:54, load average: 10.65, 4.65, 1.89 conn1 [ok]: /var/run/postgresql:5432 postgres@p (ver: 9.6.2, up 1 day 04:05:15) %cpu: 77.4 us, 9.6 sy, 0.0 ni, 12.9 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st activity: 73/100 conns, 0/0 prepared, 12 idle, 0 idle_xact, 61 active, 0 waiting, 0 others MiB mem: 32124 total, 215 free, 25469 used, 6440 buff/cached autovacuum: 0/3 workers/max, 0 manual, 0 wraparound, 00:00:00 vac_maxtime MiB swap: 15257 total, 15257 free, 0 used, 0/0 dirty/writeback statements: 76074 stmt/s, 0.263 stmt_avgtime, 00:00:00 xact_maxtime, 00:00:00 prep_maxtime user database t_all_t t_read_t t_write_t t_cpu_t all_t read_t write_t cpu_t calls queryid query postgres pgbench_6gb 02:14:30 00:02:45 00:00:00 02:11:45 909 0 0 909 63551 e8e1cdb2da SELECT abalance FROM pgbench_accounts WHERE aid = 7287471; postgres pgbench_6gb 01:07:36 00:00:16 00:00:00 01:07:19 0 0 0 0 0 192353e099 UPDATE pgbench_accounts SET abalance = abalance + ? WHERE aid = postgres pgbench_6gb 00:30:17 00:00:00 00:00:00 00:30:17 0 0 0 0 0 e7766dd7c6 UPDATE pgbench_branches SET bbalance = bbalance + ? WHERE bid = postgres pgbench_6gb 00:29:07 00:00:00 00:00:00 00:29:07 0 0 0 0 0 5372cff023 UPDATE pgbench_tellers SET tbalance = tbalance + ? WHERE tid = ? postgres pgbench_6gb 00:16:05 00:00:00 00:00:00 00:16:05 0 0 0 0 0 7a4d34a918 INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES postgres pgbench_64gb 47:40:16 47:35:18 00:00:00 00:04:57 0 0 0 0 0 94ffafcb30 UPDATE pgbench_accounts SET abalance = abalance + ? WHERE aid = postgres pgbench_64gb 23:51:51 23:48:08 00:00:00 00:03:42 0 0 0 0 0 111df3ad65 SELECT abalance FROM pgbench_accounts WHERE aid = ?; postgres pgbench_64gb 00:01:22 00:00:08 00:00:00 00:01:13 0 0 0 0 0 e192b43faf UPDATE pgbench_branches SET bbalance = bbalance + ? WHERE bid = postgres pgbench_64gb 00:01:31 00:00:18 00:00:00 00:01:13 0 0 0 0 0 45b6b13d62 UPDATE pgbench_tellers SET tbalance = tbalance + ? WHERE tid = ? postgres pgbench_64gb 00:00:42 00:00:00 00:00:00 00:00:42 0 0 0 0 0 e7cc060768 INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES postgres pgbench_6gb 00:00:41 00:00:00 00:00:00 00:00:41 0 0 0 0 0 7cbfcd7045 END; postgres pgbench_6gb 00:00:35 00:00:00 00:00:00 00:00:35 0 0 0 0 0 250dbbb915 BEGIN; Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await r_await w_await %util sda: 0.00 0.00 0.00 28.71 0.00 0.22 16.00 0.00 0.00 0.00 0.00 0.00 sda1: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 sda2: 0.00 0.00 0.00 28.71 0.00 0.22 16.00 0.00 0.00 0.00 0.00 0.00 sdb: 0.00 0.99 17.82 0.00 0.15 0.00 16.89 0.00 0.22 0.22 0.00 0.40 sdb1: 0.00 0.99 17.82 0.00 0.15 0.00 16.89 0.00 0.22 0.22 0.00 0.40
  • 29. Reports based on pg_stat_statements. Use queryid and "G" hotkey. pg_stat_statements reports02 dataegret.com
  • 30. IO consuming query02 dataegret.com summary: total_time: 75:59:21, cpu_time: 04:50:58, io_time: 71:08:23 (ALL: 100.00%, CPU: 6.38%, IO: 93.62%), total queries: 1,090,573,273 query info: usename: postgres, datname: pgbench_64gb, calls (relative to all queries): 4,826,787 (0.44%), rows (relative to all queries): 4,826,787 (0.53%), total time (relative to all queries): 47:21:38 (ALL: 62.3%, CPU: 1.7%, IO: 66.5%), average time (only for this query): 35.32ms, cpu_time: 0.06ms, io_time: 35.26ms, (ALL: 100.0%, CPU: 0.2%, IO: 99.8%), query text (id: 94ffafcb30): UPDATE pgbench_accounts SET abalance = abalance + ? WHERE aid = ?;
  • 31. CPU consuming query02 dataegret.com summary: total_time: 75:56:34, cpu_time: 04:50:04, io_time: 71:06:29 (ALL: 100.00%, CPU: 6.37%, IO: 93.63%), total queries: 1,087,323,630 query info: usename: postgres, datname: pgbench_6gb, calls (relative to all queries): 531,640,449 (48.89%), rows (relative to all queries): 531,640,449 (58.59%), total time (relative to all queries): 02:12:35 (ALL: 2.9%, CPU: 44.8%, IO: 0.1%), average time (only for this query): 0.01ms, cpu_time: 0.01ms, io_time: 0.00ms, (ALL: 100.0%, CPU: 100.0%, IO: 0.0%), query text (id: e8e1cdb2da): SELECT abalance FROM pgbench_accounts WHERE aid = 7287471;
  • 32. using pg_stat_statements you able to find: • frequently called queries; • queries that return highest number of rows; • queries caused buffers IO; • cpu hog queries; • disk hog queries (read/write); • queries with IO on temp files; • queries with IO on temp tables; • use sorting and filtering; • reports. pg_stat_statements summary02 dataegret.com
  • 33. • Health checks and load spikes. • Hidden problems. • Clients' activity. • Streaming replication. Troubleshooting cases02 dataegret.com
  • 34. Sequential scans. Database’s unwanted events. Unused indexes. Tables' sizes. Hidden problems02 dataegret.com
  • 35. Sequential scans: • might increase time of query execution; • extra IO impact on large tables. But OK for OLAP workload. Sequential scans02 dataegret.com
  • 36. Sequential scans02 dataegret.com pgcenter: 2017-04-08 11:10:14, load average: 3.09, 1.03, 0.37 conn1 [ok]: /var/run/postgresql:5432 %cpu: 91.8 us, 0.2 sy, 0.0 ni, 8.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st activity: 12/100 conns, 0/0 prepa MiB mem: 32124 total, 291 free, 25471 used, 6362 buff/cached autovacuum: 0/3 workers/max, 0 man MiB swap: 15257 total, 15257 free, 0 used, 0/0 dirty/writeback statements: 0 stmt/s, 0.000 stmt_a relation seq_scan seq_read idx_scan idx_fetch inserts updates deletes hot_updates live dead public.ycsb_metrics 43 43000000 129 4397052 0 0 0 0 0 0 public.pgbench_tellers 0 0 0 0 0 0 0 0 0 0 public.pgbench_history 0 0 0 0 0 0 0 0 0 0 public.pgbench_branches 0 0 0 0 0 0 0 0 0 0 public.pgbench_accounts 0 0 0 0 0 0 0 0 0 0
  • 37. Sequential scans02 dataegret.com pgcenter: 2017-04-08 11:10:50, load average: 6.73, 2.17, 0.78 conn1 [ok]: /var/run/postgresql:5432 %cpu: 91.6 us, 0.2 sy, 0.0 ni, 8.3 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st activity: 12/100 conns, 0/0 prepa MiB mem: 32124 total, 290 free, 25471 used, 6363 buff/cached autovacuum: 0/3 workers/max, 0 man MiB swap: 15257 total, 15257 free, 0 used, 0/0 dirty/writeback statements: 0 stmt/s, 0.000 stmt_a relation heap_read heap_hit idx_read idx_hit toast_read toast_hit tidx_read tidx_hit public.ycsb_metrics 0 7675872 0 93752 0 0 0 0 public.pgbench_tellers 0 0 0 0 0 0 0 0 public.pgbench_history 0 0 0 0 0 0 0 0 public.pgbench_branches 0 0 0 0 0 0 0 0 public.pgbench_accounts 0 0 0 0 0 0 0 0
  • 38. Sequential scans02 dataegret.com pgcenter: 2017-04-08 11:13:02, load average: 10.66, 5.43, 2.18 conn1 [ok]: /var/run/postgresql:5432 postgres@p (ver: 9.6.2, up 1 day %cpu: 91.9 us, 0.3 sy, 0.0 ni, 7.8 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st activity: 12/100 conns, 0/0 prepared, 0 idle, 0 idle_xact, 12 active, MiB mem: 32124 total, 286 free, 25475 used, 6363 buff/cached autovacuum: 0/3 workers/max, 0 manual, 0 wraparound, 00:00:00 MiB swap: 15257 total, 15257 free, 0 used, 0/0 dirty/writeback statements: 160 stmt/s, 0.253 stmt_avgtime, 00:00:00 xact_maxtime, 00:00:00 user database t_calls t_rows calls rows queryid query postgres pgbench_6gb 11191 11186446 38 38292 3702386801 select id,inserted_at,severity,payload from ycsb_metrics where ycsb_sensor = ?; postgres pgbench_6gb 11220 1122000 38 3800 e55c44ee4a select id,ycsb_sensor,extra1 from ycsb_metrics where severity = ? order by inserted_at postgres pgbench_6gb 11221 1122010 38 3800 18d47af42e select id,inserted_at,severity,payload,extra1,extra2,extra3 from ycsb_metrics where postgres pgbench_6gb 54 6425 1 119 3cadff41ef SELECT a.rolname AS user, d.datname AS database, sum(p.calls) AS t_calls, sum(p.rows) postgres pgbench_6gb 11224 11224 39 39 65087e0adb select ycsb_sensor,inserted_at,severity,payload from ycsb_metrics where id = ?;
  • 40. Unwanted events02 dataegret.com pgcenter: 2017-04-08 11:40:07, load average: 10.56, 4.80, 2.28 conn1 [ok]: /var/run/postgresql:5432 postgres@p (ver: 9.6.2, up 1 day %cpu: 91.9 us, 2.6 sy, 0.0 ni, 5.5 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st activity: 12/100 conns, 0/0 prepared, 7 idle, 0 idle_xact, 5 active, MiB mem: 32124 total, 267 free, 25475 used, 6382 buff/cached autovacuum: 0/3 workers/max, 0 manual, 0 wraparound, 00:00:00 MiB swap: 15257 total, 15257 free, 0 used, 0/0 dirty/writeback statements: 3535 stmt/s, 0.255 stmt_avgtime, 00:00:00 xact_maxtime, datname commit rollback reads hits returned fetched inserts updates deletes conflicts deadlocks tmp_files tmp_bytes read_t write_t pgbench_64gb 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 pgbench_6gb 154 37 0 918112 40826627 3826627 22 1 0 0 0 0 0 0 0 postgres 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 template0 2 0 0 69 978 11 0 0 0 0 0 0 0 0 0 template1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  • 41. Rollbacks - check postgres logs and application. Deadlocks - enable log_lock_waits, check logs. Temp files - enable log_temp_files, check logs, pg_stat_statements. Recovery conflicts - check postgres logs, standby’s queries. Unwanted events summary02 dataegret.com
  • 42. Unused indexes are bad: • consume disk space; • extra writes operations; • slow down INSERT/UPDATE/DELETEs; • extra work for (auto)VACUUM. Unused indexes02 dataegret.com
  • 43. Unused indexes02 dataegret.com pgcenter: 2017-04-08 11:45:20, load average: 0.09, 2.08, 1.87 conn1 [ok]: /var/run/postgresql:5432 postgre %cpu: 0.2 us, 0.0 sy, 0.0 ni, 99.8 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st activity: 1/100 conns, 0/0 prepared, 0 MiB mem: 32124 total, 282 free, 25462 used, 6380 buff/cached autovacuum: 0/3 workers/max, 0 manual, 0 MiB swap: 15257 total, 15257 free, 0 used, 0/0 dirty/writeback statements: 6 stmt/s, 0.255 stmt_avgtime, relation index idx_scan idx_tup_read idx_tup_fetch idx_read idx_hit public.ycsb_metrics ycsb_metrics_ycsb_sensor_idx 0 0 0 0 0 public.ycsb_metrics ycsb_metrics_severity_idx 0 0 0 0 0 public.ycsb_metrics ycsb_metrics_pkey 0 0 0 0 0 public.ycsb_metrics ycsb_metrics_inserted_at_idx 0 0 0 0 0 public.pgbench_tellers pgbench_tellers_pkey 0 0 0 0 0 public.pgbench_branches pgbench_branches_pkey 0 0 0 0 0 public.pgbench_accounts pgbench_accounts_pkey 0 0 0 0 0
  • 44. How fast do tables and their indexes grow? • pg_relation_size(); • pg_total_relation_size(); • pg_stat_user_tables. Tables' sizes02 dataegret.com
  • 45. Table’s sizes02 dataegret.com pgcenter: 2017-04-08 12:03:55, load average: 3.29, 0.85, 0.81 %cpu: 79.1 us, 8.8 sy, 0.0 ni, 12.1 id, 0.0 wa, 0.0 hi, 0.1 si, 0.0 st MiB mem: 32124 total, 230 free, 25471 used, 6423 buff/cached MiB swap: 15257 total, 15257 free, 0 used, 29/0 dirty/writeback relation total_size rel_size idx_size total_change rel_change idx_change public.ycsb_metrics 362800 237312 125488 4208 2464 1744 public.pgbench_tellers 2984 2160 824 0 0 0 public.pgbench_history 0 0 0 0 0 0 public.pgbench_branches 1944 1624 320 0 0 0 public.pgbench_accounts 6934296 5967448 966848 0 0 0
  • 46. These are not all cases. There are many other use cases. Hidden problems summary02 dataegret.com
  • 47. • Health checks and load spikes. • Hidden problems. • Clients' activity. • Streaming replication. Troubleshooting cases02 dataegret.com
  • 48. A lot of active clients. Idle transactions. Waiting clients. Age of the longest transaction. Autovacuum. Clients' activity02 dataegret.com
  • 49. Clients' activity02 dataegret.com pgcenter: 2017-04-08 14:02:32, load average: 12.65, 10.19, 5.50 conn1 [ok]: /var/run/postgresql:5432 postgres@p (ver: 9.6.2, up 1 day 20:14:53) %cpu: 69.0 us, 10.5 sy, 0.0 ni, 20.3 id, 0.2 wa, 0.0 hi, 0.0 si, 0.0 st activity: 11/100 conns, 0/0 prepared, 0 idle, 0 idle_xact, 11 active, 3 waiting, 0 others MiB mem: 32124 total, 224 free, 25466 used, 6434 buff/cached autovacuum: 0/3 workers/max, 0 manual, 0 wraparound, 00:00:00 vac_maxtime MiB swap: 15257 total, 15257 free, 0 used, 1/0 dirty/writeback statements: 80598 stmt/s, 0.246 stmt_avgtime, 00:00:00 xact_maxtime, 00:00:00 prep_maxtime pid cl_addr cl_port datname usename state wait_etype wait_event xact_age query_age change_age query 21304 -1 pgbench_6gb postgres active 00:00:00 00:00:00 00:00:00 UPDATE pgbench_accounts SET abalance = abalance + 2099 WH 21303 -1 pgbench_6gb postgres active 00:00:00 00:00:00 00:00:00 UPDATE pgbench_accounts SET abalance = abalance + 1822 WH 21302 -1 pgbench_6gb postgres active 00:00:00 00:00:00 00:00:00 UPDATE pgbench_accounts SET abalance = abalance + 1989 WH 21301 -1 pgbench_6gb postgres active 00:00:00 00:00:00 00:00:00 UPDATE pgbench_accounts SET abalance = abalance + 2305 WH 21300 -1 pgbench_6gb postgres active LWLockNamed XidGenLock 00:00:00 00:00:00 00:00:00 UPDATE pgbench_accounts SET abalance = abalance + 762 WHE 21299 -1 pgbench_6gb postgres active 00:00:00 00:00:00 00:00:00 UPDATE pgbench_accounts SET abalance = abalance + 771 WHE 21298 -1 pgbench_6gb postgres active LWLockTranche buffer_content 00:00:00 00:00:00 00:00:00 UPDATE pgbench_accounts SET abalance = abalance + 4219 WH 21297 -1 pgbench_6gb postgres active 00:00:00 00:00:00 00:00:00 UPDATE pgbench_accounts SET abalance = abalance + -2077 W 21296 -1 pgbench_6gb postgres active 00:00:00 00:00:00 00:00:00 UPDATE pgbench_accounts SET abalance = abalance + -2311 W 21295 -1 pgbench_6gb postgres active LWLockNamed XidGenLock 00:00:00 00:00:00 00:00:00 UPDATE pgbench_accounts SET abalance = abalance + 4555 WH
  • 50. Avoid: • idle and long transactions cause bloat; • deadlocks frustrate users. Possible solutuions: • cancel or terminate them; • inspect an application. Clients' activity summary02 dataegret.com
  • 51. • Health checks and load spikes. • Hidden problems. • Clients' activity. • Streaming replication. Troubleshooting cases02 dataegret.com
  • 52. Replication issues: • replication lag; • standby’s queries. Streaming replication02 dataegret.com
  • 53. pg_stat_replication & co02 dataegret.com pgcenter: 2017-04-08 14:13:49, load average: 0.04, 3.10, 4.61 conn1 [ok]: /var/run/postgresql:5432 postgres@p %cpu: 0.0 us, 0.1 sy, 0.0 ni, 99.9 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st activity: 1/100 conns, 0/0 prepared, 0 idle, MiB mem: 32124 total, 232 free, 25461 used, 6431 buff/cached autovacuum: 0/3 workers/max, 0 manual, 0 wra MiB swap: 15257 total, 15257 free, 0 used, 0/0 dirty/writeback statements: 6 stmt/s, 0.241 stmt_avgtime, 00: client user name state mode xlog pending write flush replay total_lag xact_age time_age 10.6.6.9 replica walreceiver streaming async 2485 0 0 0 410480 410480 524824 00:02:14 10.6.6.7 replica walreceiver streaming async 2485 0 0 0 0 0 10.6.6.6 replica walreceiver streaming async 2485 0 0 0 128 128 14 00:00:01
  • 54. • Health checks and load spikes. • Hidden problems. • Clients activity. • Streaming replication. Troubleshooting cases02 dataegret.com
  • 55. Postgres offers a lot of stats. pgCenter offers handy stats' representation. pgCenter helps to solve many types of issues. It's still work in progress. Summary02 dataegret.com
  • 56. pgCener – https://github.com/lesovsky/pgcenter Slides – https://slideshare.net/alexeylesovsky/presentations DataEgret – http://dataegret.com DataEgret Blog – https://blog.postgresql-consulting.com Links02 dataegret.com
  • 57. Thanks for watching! dataegret.com alexey.lesovsky@dataegret.com