SlideShare ist ein Scribd-Unternehmen logo
1 von 64
Downloaden Sie, um offline zu lesen
Managing PostgreSQL with pgCenter
PgConf EU 2016, Estonia, Tallinn
Alexey Lesovsky
lesovsky@pgco.me
I am a PostgreSQL DBA:
● Linux administration, internals;
● and PostgreSQL of course.
Work in PostgreSQL-Consulting:
● Consulting, support, troubleshooting, profiling, training, etc...
https://goo.gl/NYRFQV
About me
PostgreSQL statistics overview.
PgCenter – quick overview.
Management and troubleshoot with pgCenter.
Outline
+ The most subsystems and objects have stats.
+ Getting stats is quite easy.
– Stats are provided as counters.
– No history or what happened X minutes ago?
– No builtin tools, only psql and hand-made queries.
PostgreSQL statistics
Write Ahead Log
Shared
Buffers
Buffers IO Autovacuum Workers
Autovacuum Launcher
Background Workers
Indexes IO
Query Execution
Query Planning
Client Backends Postmaster
Tables IO
Logger Process Stats Collector
Logical
Replication
WAL Sender
Process
Archiver
Process
Background
Writer
Checkpointer
Process
Network Storage
Recovery Process
WAL Receiver Process
Tables/Indexes Data Files
pg_stat_all_tables
pg_current_xlog_location
pg_replication_slots
pg_stat_replication
pg_stat_archiver
pg_stat_database_conflicts
pg_buffercache
pg_stat_database
pg_stat_activity
pg_stat_user_tables
pg_stat_database
pg_stat_bgwrier
pgstattuplepg_table_size
pg_database_size
pg_index_size
pg_stat_activity
EXPLAIN
pg_stat_statements
pg_locks
pg_stat_user_functions
pg_stat_all_indexes
pg_stat_database
pg_statio_all_indexes
pg_statio_all_tables
pg_xlog_location_diff
nicstat* iostat*
pg_stat_kcache
pg_stat_statements
* system tools
pg_stat_progress_vacuum
pg_stat_wal_receiver
pg_blocking_pids
Written in the C, uses libpq and ncurses.
Support PostgreSQL 9.x (9.0 ... 9.6).
Linux only.
Sources on Github.
Packages:
● ALT Linux;
● RedHat/CentOS/Fedora (pgdg, epel-testing);
● Ubuntu (Launchpad);
What is the pgCenter
Top-like interface for viewing stats.
System resource utilization (cpu, memory, storage, networking).
PostgreSQL general utilization (connections, autovacuum, qps).
Common admin tasks.
Major features
The same options as in the psql:
● pgcenter -h 127.0.0.1 -p 5432 -U postgres -d mydb
● pgcenter -U postgres mydb
● pgcenter mydb
Environment variables:
● PGHOST, PGPORT, PGUSER, PGDATABASE, PGPASSWORD
Connections file (~/.pgcenterrc).
How to run pgCenter
pgcenter: 2016-09-28 11:45:42, load average: 8.65, 8.80, 8.17 conn1 [ok]: 127.0.0.1:5432 postgres@postgres (ver: 9.6.0, up 00:29:28)
%cpu: 26.5 us, 2.6 sy, 0.0 ni, 69.8 id, 1.1 wa, 0.0 hi, 0.0 si, 0.0 st activity: 25 total, 17 idle, 1 idle_in_xact, 7 active, 0 waiting, 0 others
MiB mem: 30679 total, 258 free, 1130 used, 29291 buff/cached autovacuum: 1/8 workers/max, 0 manual, 0 wraparound, 00:08:15 vac_maxtime
MiB swap: 5119 total, 5119 free, 0 used, 3/0 dirty/writeback statements: 0 stmt/s, 0.000 stmt_avgtime, 00:08:15 xact_maxtime
datname commit rollback reads hits returned fetched inserts updates deletes conflicts deadlocks tmp_files tmp_bytes read_t write_t
prod_db 1752 0 805 29173 197095 3504 1752 5256 0 0 0 0 0 13 0
appcast 832 0 183 12448 93215 1664 832 2496 0 0 0 0 0 2 0
template1 0 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
postgres 5 1 0 0 0 0 0 0 0 0 0 0 0 0 0
Interface overview
pgcenter: 2016-09-28 11:45:42, load average: 8.65, 8.80, 8.17 conn1 [ok]: 127.0.0.1:5432 postgres@postgres (ver: 9.6.0, up 00:29:28)
%cpu: 26.5 us, 2.6 sy, 0.0 ni, 69.8 id, 1.1 wa, 0.0 hi, 0.0 si, 0.0 st activity: 25 total, 17 idle, 1 idle_in_xact, 7 active, 0 waiting, 0 others
MiB mem: 30679 total, 258 free, 1130 used, 29291 buff/cached autovacuum: 1/8 workers/max, 0 manual, 0 wraparound, 00:08:15 vac_maxtime
MiB swap: 5119 total, 5119 free, 0 used, 3/0 dirty/writeback statements: 0 stmt/s, 0.000 stmt_avgtime, 00:08:15 xact_maxtime
datname commit rollback reads hits returned fetched inserts updates deletes conflicts deadlocks tmp_files tmp_bytes read_t write_t
prod_db 1752 0 805 29173 197095 3504 1752 5256 0 0 0 0 0 13 0
appcast 832 0 183 12448 93215 1664 832 2496 0 0 0 0 0 2 0
template1 0 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
postgres 5 1 0 0 0 0 0 0 0 0 0 0 0 0 0
Interface overview
System metrics
pgcenter: 2016-09-28 11:45:42, load average: 8.65, 8.80, 8.17 conn1 [ok]: 127.0.0.1:5432 postgres@postgres (ver: 9.6.0, up 00:29:28)
%cpu: 26.5 us, 2.6 sy, 0.0 ni, 69.8 id, 1.1 wa, 0.0 hi, 0.0 si, 0.0 st activity: 25 total, 17 idle, 1 idle_in_xact, 7 active, 0 waiting, 0 others
MiB mem: 30679 total, 258 free, 1130 used, 29291 buff/cached autovacuum: 1/8 workers/max, 0 manual, 0 wraparound, 00:08:15 vac_maxtime
MiB swap: 5119 total, 5119 free, 0 used, 3/0 dirty/writeback statements: 0 stmt/s, 0.000 stmt_avgtime, 00:08:15 xact_maxtime
datname commit rollback reads hits returned fetched inserts updates deletes conflicts deadlocks tmp_files tmp_bytes read_t write_t
prod_db 1752 0 805 29173 197095 3504 1752 5256 0 0 0 0 0 13 0
appcast 832 0 183 12448 93215 1664 832 2496 0 0 0 0 0 2 0
template1 0 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
postgres 5 1 0 0 0 0 0 0 0 0 0 0 0 0 0
Interface overview
System metrics PostgreSQL metrics
pgcenter: 2016-09-28 11:45:42, load average: 8.65, 8.80, 8.17 conn1 [ok]: 127.0.0.1:5432 postgres@postgres (ver: 9.6.0, up 00:29:28)
%cpu: 26.5 us, 2.6 sy, 0.0 ni, 69.8 id, 1.1 wa, 0.0 hi, 0.0 si, 0.0 st activity: 25 total, 17 idle, 1 idle_in_xact, 7 active, 0 waiting, 0 others
MiB mem: 30679 total, 258 free, 1130 used, 29291 buff/cached autovacuum: 1/8 workers/max, 0 manual, 0 wraparound, 00:08:15 vac_maxtime
MiB swap: 5119 total, 5119 free, 0 used, 3/0 dirty/writeback statements: 0 stmt/s, 0.000 stmt_avgtime, 00:08:15 xact_maxtime
datname commit rollback reads hits returned fetched inserts updates deletes conflicts deadlocks tmp_files tmp_bytes read_t write_t
prod_db 1752 0 805 29173 197095 3504 1752 5256 0 0 0 0 0 13 0
appcast 832 0 183 12448 93215 1664 832 2496 0 0 0 0 0 2 0
template1 0 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
postgres 5 1 0 0 0 0 0 0 0 0 0 0 0 0 0
Interface overview
System metrics PostgreSQL metrics
Statistics values
pgcenter: 2016-09-28 11:45:42, load average: 8.65, 8.80, 8.17 conn1 [ok]: 127.0.0.1:5432 postgres@postgres (ver: 9.6.0, up 00:29:28)
%cpu: 26.5 us, 2.6 sy, 0.0 ni, 69.8 id, 1.1 wa, 0.0 hi, 0.0 si, 0.0 st activity: 25 total, 17 idle, 1 idle_in_xact, 7 active, 0 waiting, 0 others
MiB mem: 30679 total, 258 free, 1130 used, 29291 buff/cached autovacuum: 1/8 workers/max, 0 manual, 0 wraparound, 00:08:15 vac_maxtime
MiB swap: 5119 total, 5119 free, 0 used, 3/0 dirty/writeback statements: 0 stmt/s, 0.000 stmt_avgtime, 00:08:15 xact_maxtime
datname commit rollback reads hits returned fetched inserts updates deletes conflicts deadlocks tmp_files tmp_bytes read_t write_t
prod_db 1752 0 805 29173 197095 3504 1752 5256 0 0 0 0 0 13 0
appcast 832 0 183 12448 93215 1664 832 2496 0 0 0 0 0 2 0
template1 0 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
postgres 5 1 0 0 0 0 0 0 0 0 0 0 0 0 0
Interface overview
System metrics PostgreSQL metrics
Statistics valuesAdditional information
pgcenter: 2016-09-28 11:45:42, load average: 8.65, 8.80, 8.17
%cpu: 26.5 us, 2.6 sy, 0.0 ni, 69.8 id, 1.1 wa, 0.0 hi, 0.0 si, 0.0 st
MiB mem: 30679 total, 258 free, 1130 used, 29291 buff/cached
MiB swap: 5119 total, 5119 free, 0 used, 3/0 dirty/writeback
Interface overview
program name current time load average
cpu usage memory usage swap usage
pgcenter: 2016-09-28 11:45:42, load average: 8.65, 8.80, 8.17
%cpu: 26.5 us, 2.6 sy, 0.0 ni, 69.8 id, 1.1 wa, 0.0 hi, 0.0 si, 0.0 st
MiB mem: 30679 total, 258 free, 1130 used, 29291 buff/cached
MiB swap: 5119 total, 5119 free, 0 used, 3/0 dirty/writeback
Interface overview
program name current time load average
cpu usage memory usage swap usage
pgcenter: 2016-09-28 11:45:42, load average: 8.65, 8.80, 8.17
%cpu: 26.5 us, 2.6 sy, 0.0 ni, 69.8 id, 1.1 wa, 0.0 hi, 0.0 si, 0.0 st
MiB mem: 30679 total, 258 free, 1130 used, 29291 buff/cached
MiB swap: 5119 total, 5119 free, 0 used, 3/0 dirty/writeback
Interface overview
program name current time load average
cpu usage memory usage swap usage
pgcenter: 2016-09-28 11:45:42, load average: 8.65, 8.80, 8.17
%cpu: 26.5 us, 2.6 sy, 0.0 ni, 69.8 id, 1.1 wa, 0.0 hi, 0.0 si, 0.0 st
MiB mem: 30679 total, 258 free, 1130 used, 29291 buff/cached
MiB swap: 5119 total, 5119 free, 0 used, 3/0 dirty/writeback
Interface overview
program name current time load average
cpu usage memory usage swap usage
conn1 [ok]: 127.0.0.1:5432 postgres@postgres (ver: 9.6.0, up 00:29:28)
activity: 25 total, 17 idle, 1 idle_in_xact, 7 active, 0 waiting, 0 others
autovacuum: 1/8 workers/max, 0 manual, 0 wraparound, 00:08:15 vac_maxtime
statements: 689 stmt/s, 1.857 stmt_avgtime, 00:00:01 xact_maxtime
Interface overview
tab number current connection postgres version
connections vacuum operations queries/xact info
postgres uptime
conn1 [ok]: 127.0.0.1:5432 postgres@postgres (ver: 9.6.0, up 00:29:28)
activity: 25 total, 17 idle, 1 idle_in_xact, 7 active, 0 waiting, 0 others
autovacuum: 1/8 workers/max, 0 manual, 0 wraparound, 00:08:15 vac_maxtime
statements: 689 stmt/s, 1.857 stmt_avgtime, 00:00:01 xact_maxtime
Interface overview
tab number current connection postgres version
connections vacuum operations queries/xact info
postgres uptime
conn1 [ok]: 127.0.0.1:5432 postgres@postgres (ver: 9.6.0, up 00:29:28)
activity: 25 total, 17 idle, 1 idle_in_xact, 7 active, 0 waiting, 0 others
autovacuum: 1/8 workers/max, 0 manual, 0 wraparound, 00:08:15 vac_maxtime
statements: 689 stmt/s, 1.857 stmt_avgtime, 00:00:01 xact_maxtime
Interface overview
tab number current connection postgres version
connections vacuum operations queries/xact info
postgres uptime
conn1 [ok]: 127.0.0.1:5432 postgres@postgres (ver: 9.6.0, up 00:29:28)
activity: 25 total, 17 idle, 1 idle_in_xact, 7 active, 0 waiting, 0 others
autovacuum: 1/8 workers/max, 0 manual, 0 wraparound, 00:08:15 vac_maxtime
statements: 689 stmt/s, 1.857 stmt_avgtime, 00:00:01 xact_maxtime
Interface overview
tab number current connection postgres version
connections vacuum operations queries/xact info
postgres uptime
datname commit rollback reads hits returned fetched inserts updates >
prod_db 1752 0 805 29173 197095 3504 1752 5256 >
appcast 832 0 183 12448 93215 1664 832 2496 >
template1 0 0 0 0 0 0 0 0 >
template0 0 0 0 0 0 0 0 0 >
Postgres 5 1 0 0 0 0 0 0 >
Interface overview
datname commit rollback reads hits returned fetched inserts updates >
prod_db 1752 0 805 29173 197095 3504 1752 5256 >
appcast 832 0 183 12448 93215 1664 832 2496 >
template1 0 0 0 0 0 0 0 0 >
template0 0 0 0 0 0 0 0 0 >
Postgres 5 1 0 0 0 0 0 0 >
Left, Right: change sort.
F: Enable filter.
/: Change sort order – desc or asc.
Interface overview
N: open new connection in a new tab
Ctrl+D: close current tab.
1..8: switch between tabs.
W: save opened connections settings to the connfile.
General actions
d: pg_stat_databases
r: pg_stat_replication
t: pg_stat_all_tables
T: pg_statio_all_tables
i: pg_stat_all_indexes, pg_statio_all_indexes
f: pg_stat_user_functions
a: pg_stat_activity
v: pg_stat_progress_vacuum
x: pg_stat_statements
s: Relations size
Available stats
C: show config menu.
E: edit config menu.
R: reload postgres service.
Admin tasks
C: show config menu.
E: edit config menu.
R: reload postgres service.
l: show log file.
Admin tasks
C: show config menu.
E: edit config menu
R: reload postgres service.
l: show log file.
-: сancel query using pid.
_: terminate backend using pid.
Del: cancel group of queries using mask.
Shift+Del: terminate group of backends using mask.
.: show current mask, >: set new mask.
Admin tasks
C: show config menu.
E: edit config menu.
R: reload postgres service.
l: show log file.
-: cancel query using pid.
_: terminate backend using pid.
Del: cancel group of queries using mask.
Shift+Del: terminate group of backends using mask.
.: show current mask, >: set new mask.
p: open psql session.
Admin tasks
B: open iostat.
I: open nicstat.
L: tail postgres log (show the latest log lines).
Additional Information
B: open iostat.
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
sdb: 0.00 1.98 0.00 106.93 0.00 53.85 1031.33 141.19 1472.32 0.00 1472.32 100.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
sdb2: 0.00 1.98 0.00 106.93 0.00 53.85 1031.33 141.19 1472.32 0.00 1472.32 100.00
I: open nicstat.
L: tail postgres log (show the latest log lines).
Additional Information
B: open iostat.
I: open nicstat.
Interface: rMbps wMbps rPk/s wPk/s rAvs wAvs IErr OErr Coll Sat %rUtil %wUtil %Util
eth0: 592.33 7.29 52350.50 16897.03 1483.04 56.52 0.00 0.00 0.00 0.00 44.05 0.54 44.59
eth1: 119.04 1.85 10728.71 4290.10 1454.32 56.39 0.00 0.00 0.00 0.00 8.85 0.14 8.99
lo: 0.13 0.13 49.50 49.50 351.96 351.96 0.00 0.00 0.00 0.00 0.00 0.00 0.00
L: tail postgres log (show the latest log lines).
Additional Information
B: open iostat.
I: open nicstat.
L: tail postgres log (show the latest log lines).
ERROR: cannot execute SELECT FOR UPDATE in a read-only transaction
ERROR: cannot execute SELECT FOR UPDATE in a read-only transaction
LOG: checkpoint starting: time
LOG: checkpoint complete: wrote 40 buffers (0.0%); 0 transaction log file(s) added, 0 removed, 26 recycled; write=3.924 s, sync=0.
ERROR: cannot execute SELECT FOR UPDATE in a read-only transaction
Additional Information
Troubleshoot:
● quick overview, resource utilization and postgresql activity;
● autovacuum issues;
● replication problems;
● database anomalies;
● tables, indexes and functions;
● where is the space?
● bad company;
● queries investigation.
Troubleshoot
Quick overview:
● run pgCenter;
● check resources usage (cpu, mem, disk, net);
● check the postgresql usage;
● make a plan what's next.
Troubleshoot
pgcenter: 2016-09-28 12:21:45, load average: 19.81, 5.15, 3.35
%cpu: 68.6 us, 5.5 sy, 0.0 ni, 15.1 id, 10.8 wa, 0.0 hi, 0.0 si, 0.0 st
MiB mem: 30679 total, 1508 free, 1130 used, 28041 buff/cached
MiB swap: 5119 total, 552 free, 4567 used, 834/198 dirty/writeback
Troubleshoot
pgcenter: 2016-09-28 12:21:45, load average: 19.81, 5.15, 3.35
%cpu: 68.6 us, 5.5 sy, 0.0 ni, 15.1 id, 10.8 wa, 0.0 hi, 0.0 si, 0.0 st
MiB mem: 30679 total, 1508 free, 1130 used, 28041 buff/cached
MiB swap: 5119 total, 552 free, 4567 used, 834/198 dirty/writeback
load average? – check cpu/disks usage.
us – check queries/activity.
sy, si, hi – check system/kernel/hardware.
wa – check queries, disks activity.
mem/swap – revise shared_buffers/work_mem.
dirty/writeback – write activity, disks utilization.
Troubleshoot
PostgreSQL general state:
● too many connections;
● too many bad connections (waiting, idle_in_xact);
● too many vacuums, long vacuum;
● too many queries, long transactions/queries;
Troubleshoot
conn1 [ok]: 127.0.0.1:5432 postgres@postgres (ver: 9.6.0, up 05:02:50)
activity: 44 total, 2 idle, 2 idle_in_xact, 9 active, 31 waiting, 0 others
autovacuum: 6/8 workers/max, 0 manual, 6 wraparound, 02:13:02 vac_maxtime
statements: 172 stmt/s, 5.390 stmt_avgtime, 00:18:37 xact_maxtime
Troubleshoot
conn1 [ok]: 127.0.0.1:5432 postgres@postgres (ver: 9.6.0, up 05:02:50)
activity: 44 total, 2 idle, 2 idle_in_xact, 9 active, 31 waiting, 0 others
autovacuum: 6/8 workers/max, 0 manual, 6 wraparound, 02:13:02 vac_maxtime
statements: 172 stmt/s, 5.390 stmt_avgtime, 00:18:37 xact_maxtime
too many active – check activity.
idle in transactions, waiting – check activity, cancel or terminate that.
what about autovacuum worker limit? – increase the limit, play with cost parameters.
check pg_stat_progress_vacuum, disks utilization.
long transactions – cancel or terminate.
Troubleshoot
Replication problems:
● replication lag – queries with different results;
● network utilization, errors;
● disk utilization, bandwidth.
Troubleshoot
client user name state mode pending write flush replay total_lag
10.13.0.5 replica walreceiver streaming async 256 0 0 227754 228009
10.13.0.7 replica walreceiver streaming async 1248558 0 0 514 1249072
10.13.0.6 replica walreceiver streaming async 0 0 0 64 64
Troubleshoot
client user name state mode pending write flush replay total_lag
10.13.0.5 replica walreceiver streaming async 256 0 0 227754 228009
10.13.0.7 replica walreceiver streaming async 1248558 0 0 514 1249072
10.13.0.6 replica walreceiver streaming async 0 0 0 64 64
high pending – busy master/network.
high write/flush/replay – busy standby, long running queries.
Troubleshoot
Database anomalies:
● rollbacks;
● deadlocks;
● recovery conflicts;
● temporary files.
Troubleshoot
datname commit rollback reads hits returned fetched inserts updates deletes conflicts deadlocks tmp_files tmp_bytes read_t write_t
pgbench 11845 0 0 61663 11845 0 0 11845 0 0 0 4 85725 0 0
staging 1854 10 0 128 1844 0 1844 0 0 0 0 0 0 0 0
template1 0 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
Postgres 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Troubleshoot
datname commit rollback reads hits returned fetched inserts updates deletes conflicts deadlocks tmp_files tmp_bytes read_t write_t
pgbench 11845 0 0 61663 11845 0 0 11845 0 0 0 4 85725 0 0
staging 1854 10 0 128 1844 0 1844 0 0 0 0 0 0 0 0
template1 0 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
Postgres 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0
rollbacks – check postgres and application logs for errors.
deadlocks – check postgres log, review pg_locks.
conflicts – check pg_stat_database_conflicts, raise delays, enable feedback.
temporary files – check logs, pg_stat_statements, work_mem (carefully).
Troubleshoot
Tables activity:
● sequential scans;
● abnormal activity;
Troubleshoot
relation seq_scan seq_read idx_scan idx_fetch inserts updates deletes hot_updates live dead
public.job_stats 94 116090 0 0 0 0 0 0 0 0
public.feed_settings 10924 10924 0 0 0 10924 0 10924 0 7
public.feed_actions 0 0 35 1275 0 68 3 0 0 3
public.job_boards 0 0 0 0 0 0 0 0 0 0
Troubleshoot
relation seq_scan seq_read idx_scan idx_fetch inserts updates deletes hot_updates live dead
public.job_stats 94 116090 0 0 0 0 0 0 0 0
public.feed_settings 924 924 0 0 0 924 0 924 0 7
public.feed_actions 0 0 35 1275 0 68 3 0 0 3
public.job_boards 0 0 0 0 0 0 0 0 0 0
sequential scans – no index or broken planner stats.
abnormal activity – too many CRUD, check pg_statio_all_tables.
Troubleshoot
Index activity:
● unused indexes;
Troubleshoot
relation index idx_scan idx_tup_read idx_tup_fetch idx_read idx_hit
public.job_bodies job_bodies_pkey 850 850 850 0 14560
public.job_bodies job_bodies_refcount_idx 850 880 850 0 14960
public.job_bodies job_bodies_reftype_idx 170 255 170 1136 7024
public.job_bodies job_bodies_spc2_idx 0 0 0 0 0
public.job_bodies job_bodies_spc5_idx 0 0 0 0 0
Troubleshoot
relation index idx_scan idx_tup_read idx_tup_fetch idx_read idx_hit
public.job_bodies job_bodies_pkey 850 850 850 0 14560
public.job_bodies job_bodies_refcount_idx 850 880 850 0 14960
public.job_bodies job_bodies_reftype_idx 170 255 170 1136 7024
public.job_bodies job_bodies_spc2_idx 0 0 0 0 0
public.job_bodies job_bodies_spc5_idx 0 0 0 0 0
zero idx_scan – unused indexes;
tip: before drop them, check its usage on standbys.
Troubleshoot
Functions usage:
● long running functions;
● run psql, edit function with ef funcname.
Troubleshoot
Where is the space Postgres ?
● check tables sizes (with and without indexes);
● check tables size changes;
● use filters to see interesting tables.
Troubleshoot
relation total_size rel_size idx_size total_change rel_change idx_change
public.job_bodies 7656200 6557568 1098632 312 260 58
public.job_stats_20161004 1629232 1285764 343468 37928 29920 8008
public.rules 3000 2744 256 0 0 0
public.resumes 384 224 160 0 0 0
public.versions 112 40 72 0 0 0
Troubleshoot
Bad company:
● long running queries or idle transactions;
● waiting queries/transactions;
● cancel queries or terminate backends using pid or mask;
● change age threshold to hide unwanted things.
Troubleshoot
pid cl_addr cl_port datname usename state wait_etype wait_event xact_age query_age change_age query
6942 -1 shopdb shop_app active Lock transactionid 00:10:14 00:00:17 00:00:17 update >
6930 -1 shopdb shop_app active 00:08:17 00:00:12 00:00:12 update >
3429 -1 shopdb shop_app active Lock transactionid 00:07:01 00:00:02 00:00:00 update >
3857 -1 shopdb shop_app active 00:00:00 00:00:00 00:00:00 select >
5781 -1 shopdb shop_bg active 00:03:29 00:00:01 00:00:01 select >
6901 -1 shopdb shop_bg active 00:01:10 00:00:01 00:00:01 select >
Troubleshoot
pid cl_addr cl_port datname usename state wait_etype wait_event xact_age query_age change_age query
6942 -1 shopdb shop_app active Lock transactionid 00:10:14 00:00:17 00:00:17 update >
6930 -1 shopdb shop_app active 00:08:17 00:00:12 00:00:12 update >
3429 -1 shopdb shop_app active Lock transactionid 00:07:01 00:00:02 00:00:00 update >
3857 -1 shopdb shop_app active 00:00:00 00:00:00 00:00:00 select >
5781 -1 shopdb shop_bg active 00:03:29 00:00:01 00:00:01 select >
6901 -1 shopdb shop_bg active 00:01:10 00:00:01 00:00:01 select >
idle in transaction, waiting – cancel or terminate.
use age thresholds and filters.
Troubleshoot
Query investigation:
● cpu- or disk hog queries;
● most called queries;
● queries doing a lot of IO;
● pg_stat_statements;
● query reports;
● looking for a query example;
● run psql and EXPLAIN ANALYZE query;
● rewrite a query, build an index, move a query to the standby, blame
developers...
Troubleshoot
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:56:05 00:00:00 00:00:00 00:56:05 254 0 0 254 10790 e19c70cd44 update >
postgres pgbench 00:00:32 00:00:00 00:00:00 00:00:32 4 0 0 4 10790 cfc329b478 commit;
postgres pgbench 00:00:28 00:00:00 00:00:00 00:00:28 4 0 0 4 10790 731392f8ec begin;
postgres pgbench 00:35:03 00:14:01 00:00:00 00:21:02 85 22 0 107 1587 a357c10e55 select >
postgres pgbench 00:22:27 00:08:15 00:00:00 00:14:12 51 10 0 61 854 4db337810e update >
postgres pgbench 00:07:23 00:00:00 00:00:00 00:07:23 11 0 0 11 59 6acc738af9 select >
Troubleshoot
summary:
total_time: 01:03:47, cpu_time: 00:59:38, io_time: 00:04:09 (ALL: 100.00%, CPU: 93.47%, IO: 6.53%),
total queries: 258,798,086
query info:
usename: streamcast,
datname: outpost,
calls (relative to all queries): 86,250,226 (33.33%),
rows (relative to all queries): 86,250,226 (94.46%),
total time (relative to all queries): 00:58:14 (ALL: 91.3%, CPU: 97.7%, IO: 0.0%),
average time (only for this query): 0.04ms, cpu_time: 0.04ms, io_time: 0.00ms, (ALL: 100.0%, CPU: 100.0%, IO: 0.0%),
query text (id: 14a58a3b9f):
SELECT tags.tg_id FROM tags WHERE tags.id IN (?, ?, ?) AND (id NOT IN (?)) GROUP BY id HAVING count(distinct tg_id) > ? LIMIT ?
Troubleshoot
pgCenter has many features but:
● psql is always available – 'p' hotkey.
● use the help – 'h' hotkey.
In the end
pgCenter is useful:
● to check what's going on;
● for quick overview;
● to make simple admin operations;
● to manage postgres easier and faster (I hope).
In the end
Alexey Lesovsky
lesovsky@pgco.me
PostgreSQL–Consulting: Data maintenance as its best.
http://postgresql-consulting.com
Questions?

Weitere ähnliche Inhalte

Was ist angesagt?

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
 
Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Alexey Lesovsky
 
Advanced Postgres Monitoring
Advanced Postgres MonitoringAdvanced Postgres Monitoring
Advanced Postgres MonitoringDenish Patel
 
PostgreSQL Streaming Replication Cheatsheet
PostgreSQL Streaming Replication CheatsheetPostgreSQL Streaming Replication Cheatsheet
PostgreSQL Streaming Replication CheatsheetAlexey Lesovsky
 
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 работает с диском
Как PostgreSQL работает с дискомКак PostgreSQL работает с диском
Как PostgreSQL работает с дискомPostgreSQL-Consulting
 
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
 
XtraDB 5.7: key performance algorithms
XtraDB 5.7: key performance algorithmsXtraDB 5.7: key performance algorithms
XtraDB 5.7: key performance algorithmsLaurynas Biveinis
 
collectd & PostgreSQL
collectd & PostgreSQLcollectd & PostgreSQL
collectd & PostgreSQLMark Wong
 
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
 
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
 
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 database administration volume 1
Postgresql database administration volume 1Postgresql database administration volume 1
Postgresql database administration volume 1Federico Campoli
 
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
 
pg / shardman: шардинг в PostgreSQL на основе postgres / fdw, pg / pathman и ...
pg / shardman: шардинг в PostgreSQL на основе postgres / fdw, pg / pathman и ...pg / shardman: шардинг в PostgreSQL на основе postgres / fdw, pg / pathman и ...
pg / shardman: шардинг в PostgreSQL на основе postgres / fdw, pg / pathman и ...Ontico
 
Sessionization with Spark streaming
Sessionization with Spark streamingSessionization with Spark streaming
Sessionization with Spark streamingRamūnas Urbonas
 
Мастер-класс "Логическая репликация и Avito" / Константин Евтеев, Михаил Тюр...
Мастер-класс "Логическая репликация и Avito" / Константин Евтеев,  Михаил Тюр...Мастер-класс "Логическая репликация и Avito" / Константин Евтеев,  Михаил Тюр...
Мастер-класс "Логическая репликация и Avito" / Константин Евтеев, Михаил Тюр...Ontico
 
Mastering PostgreSQL Administration
Mastering PostgreSQL AdministrationMastering PostgreSQL Administration
Mastering PostgreSQL AdministrationEDB
 

Was ist angesagt? (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
 
Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.
 
PostgreSQL Replication Tutorial
PostgreSQL Replication TutorialPostgreSQL Replication Tutorial
PostgreSQL Replication Tutorial
 
Advanced Postgres Monitoring
Advanced Postgres MonitoringAdvanced Postgres Monitoring
Advanced Postgres Monitoring
 
PostgreSQL Streaming Replication Cheatsheet
PostgreSQL Streaming Replication CheatsheetPostgreSQL Streaming Replication Cheatsheet
PostgreSQL Streaming Replication Cheatsheet
 
PostgreSQL Meetup Berlin at Zalando HQ
PostgreSQL Meetup Berlin at Zalando HQPostgreSQL Meetup Berlin at Zalando HQ
PostgreSQL Meetup Berlin at Zalando HQ
 
Как PostgreSQL работает с диском
Как PostgreSQL работает с дискомКак PostgreSQL работает с диском
Как PostgreSQL работает с диском
 
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
 
XtraDB 5.7: key performance algorithms
XtraDB 5.7: key performance algorithmsXtraDB 5.7: key performance algorithms
XtraDB 5.7: key performance algorithms
 
collectd & PostgreSQL
collectd & PostgreSQLcollectd & PostgreSQL
collectd & 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
 
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...
 
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 database administration volume 1
Postgresql database administration volume 1Postgresql database administration volume 1
Postgresql database administration volume 1
 
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
 
pg / shardman: шардинг в PostgreSQL на основе postgres / fdw, pg / pathman и ...
pg / shardman: шардинг в PostgreSQL на основе postgres / fdw, pg / pathman и ...pg / shardman: шардинг в PostgreSQL на основе postgres / fdw, pg / pathman и ...
pg / shardman: шардинг в PostgreSQL на основе postgres / fdw, pg / pathman и ...
 
Sessionization with Spark streaming
Sessionization with Spark streamingSessionization with Spark streaming
Sessionization with Spark streaming
 
Мастер-класс "Логическая репликация и Avito" / Константин Евтеев, Михаил Тюр...
Мастер-класс "Логическая репликация и Avito" / Константин Евтеев,  Михаил Тюр...Мастер-класс "Логическая репликация и Avito" / Константин Евтеев,  Михаил Тюр...
Мастер-класс "Логическая репликация и Avito" / Константин Евтеев, Михаил Тюр...
 
Strategic autovacuum
Strategic autovacuumStrategic autovacuum
Strategic autovacuum
 
Mastering PostgreSQL Administration
Mastering PostgreSQL AdministrationMastering PostgreSQL Administration
Mastering PostgreSQL Administration
 

Andere mochten auch

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
 
Streaming replication in practice
Streaming replication in practiceStreaming replication in practice
Streaming replication in practiceAlexey Lesovsky
 
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya Kosmodemiansky
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya KosmodemianskyPostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya Kosmodemiansky
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya KosmodemianskyPostgreSQL-Consulting
 
Teaching PostgreSQL to new people
Teaching PostgreSQL to new peopleTeaching PostgreSQL to new people
Teaching PostgreSQL to new peopleTomek Borek
 
Managing thousands of databases
Managing thousands of databasesManaging thousands of databases
Managing thousands of databasesEmre Hasegeli
 
Девять кругов ада или PostgreSQL Vacuum / Алексей Лесовский (PostgreSQL-Consu...
Девять кругов ада или PostgreSQL Vacuum / Алексей Лесовский (PostgreSQL-Consu...Девять кругов ада или PostgreSQL Vacuum / Алексей Лесовский (PostgreSQL-Consu...
Девять кругов ада или PostgreSQL Vacuum / Алексей Лесовский (PostgreSQL-Consu...Ontico
 
Gbroccolo pgconfeu2016 pgnfs
Gbroccolo pgconfeu2016 pgnfsGbroccolo pgconfeu2016 pgnfs
Gbroccolo pgconfeu2016 pgnfsGiuseppe Broccolo
 
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
 
Advanced WAL File Management With OmniPITR
Advanced WAL File Management With OmniPITRAdvanced WAL File Management With OmniPITR
Advanced WAL File Management With OmniPITRRobert Treat
 
Out of the Box Replication in Postgres 9.4(PgCon)
Out of the Box Replication in Postgres 9.4(PgCon)Out of the Box Replication in Postgres 9.4(PgCon)
Out of the Box Replication in Postgres 9.4(PgCon)Denish Patel
 
Think_your_Postgres_backups_and_recovery_are_safe_lets_talk.pptx
Think_your_Postgres_backups_and_recovery_are_safe_lets_talk.pptxThink_your_Postgres_backups_and_recovery_are_safe_lets_talk.pptx
Think_your_Postgres_backups_and_recovery_are_safe_lets_talk.pptxPayal Singh
 
The Essential PostgreSQL.conf
The Essential PostgreSQL.confThe Essential PostgreSQL.conf
The Essential PostgreSQL.confRobert Treat
 
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
 
PostgreSQL Disaster Recovery with Barman
PostgreSQL Disaster Recovery with BarmanPostgreSQL Disaster Recovery with Barman
PostgreSQL Disaster Recovery with BarmanGabriele Bartolini
 
Best Practices for Becoming an Exceptional Postgres DBA
Best Practices for Becoming an Exceptional Postgres DBA Best Practices for Becoming an Exceptional Postgres DBA
Best Practices for Becoming an Exceptional Postgres DBA EDB
 

Andere mochten auch (20)

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
 
Streaming replication in practice
Streaming replication in practiceStreaming replication in practice
Streaming replication in practice
 
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya Kosmodemiansky
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya KosmodemianskyPostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya Kosmodemiansky
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya Kosmodemiansky
 
Teaching PostgreSQL to new people
Teaching PostgreSQL to new peopleTeaching PostgreSQL to new people
Teaching PostgreSQL to new people
 
Managing thousands of databases
Managing thousands of databasesManaging thousands of databases
Managing thousands of databases
 
Девять кругов ада или PostgreSQL Vacuum / Алексей Лесовский (PostgreSQL-Consu...
Девять кругов ада или PostgreSQL Vacuum / Алексей Лесовский (PostgreSQL-Consu...Девять кругов ада или PostgreSQL Vacuum / Алексей Лесовский (PostgreSQL-Consu...
Девять кругов ада или PostgreSQL Vacuum / Алексей Лесовский (PostgreSQL-Consu...
 
Gbroccolo pgconfeu2016 pgnfs
Gbroccolo pgconfeu2016 pgnfsGbroccolo pgconfeu2016 pgnfs
Gbroccolo pgconfeu2016 pgnfs
 
Multimaster
MultimasterMultimaster
Multimaster
 
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
 
Pro Postgres 9
Pro Postgres 9Pro Postgres 9
Pro Postgres 9
 
Advanced WAL File Management With OmniPITR
Advanced WAL File Management With OmniPITRAdvanced WAL File Management With OmniPITR
Advanced WAL File Management With OmniPITR
 
Out of the Box Replication in Postgres 9.4(PgCon)
Out of the Box Replication in Postgres 9.4(PgCon)Out of the Box Replication in Postgres 9.4(PgCon)
Out of the Box Replication in Postgres 9.4(PgCon)
 
Think_your_Postgres_backups_and_recovery_are_safe_lets_talk.pptx
Think_your_Postgres_backups_and_recovery_are_safe_lets_talk.pptxThink_your_Postgres_backups_and_recovery_are_safe_lets_talk.pptx
Think_your_Postgres_backups_and_recovery_are_safe_lets_talk.pptx
 
The Essential PostgreSQL.conf
The Essential PostgreSQL.confThe Essential PostgreSQL.conf
The Essential PostgreSQL.conf
 
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
 
PostgreSQL Disaster Recovery with Barman
PostgreSQL Disaster Recovery with BarmanPostgreSQL Disaster Recovery with Barman
PostgreSQL Disaster Recovery with Barman
 
Best Practices for Becoming an Exceptional Postgres DBA
Best Practices for Becoming an Exceptional Postgres DBA Best Practices for Becoming an Exceptional Postgres DBA
Best Practices for Becoming an Exceptional Postgres DBA
 
Scaling postgres
Scaling postgresScaling postgres
Scaling postgres
 

Ähnlich wie Managing PostgreSQL with PgCenter

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
 
Broken Performance Tools
Broken Performance ToolsBroken Performance Tools
Broken Performance ToolsC4Media
 
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
 
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
 
Analyzing OS X Systems Performance with the USE Method
Analyzing OS X Systems Performance with the USE MethodAnalyzing OS X Systems Performance with the USE Method
Analyzing OS X Systems Performance with the USE MethodBrendan Gregg
 
Monitoreo de MySQL y PostgreSQL con SQL
Monitoreo de MySQL y PostgreSQL con SQLMonitoreo de MySQL y PostgreSQL con SQL
Monitoreo de MySQL y PostgreSQL con SQLEmanuel Calvo
 
제2회난공불락 오픈소스 세미나 커널튜닝
제2회난공불락 오픈소스 세미나 커널튜닝제2회난공불락 오픈소스 세미나 커널튜닝
제2회난공불락 오픈소스 세미나 커널튜닝Tommy Lee
 
How to Diagnose Problems Quickly on Linux Servers
How to Diagnose Problems Quickly on Linux ServersHow to Diagnose Problems Quickly on Linux Servers
How to Diagnose Problems Quickly on Linux ServersRichard Cunningham
 
Performance tuning
Performance tuningPerformance tuning
Performance tuningJon Haddad
 
Как понять, что происходит на сервере? / Александр Крижановский (NatSys Lab.,...
Как понять, что происходит на сервере? / Александр Крижановский (NatSys Lab.,...Как понять, что происходит на сервере? / Александр Крижановский (NatSys Lab.,...
Как понять, что происходит на сервере? / Александр Крижановский (NatSys Lab.,...Ontico
 
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
 
Servers and Processes: Behavior and Analysis
Servers and Processes: Behavior and AnalysisServers and Processes: Behavior and Analysis
Servers and Processes: Behavior and Analysisdreamwidth
 
The true story_of_hello_world
The true story_of_hello_worldThe true story_of_hello_world
The true story_of_hello_worldfantasy zheng
 
Guide to alfresco monitoring
Guide to alfresco monitoringGuide to alfresco monitoring
Guide to alfresco monitoringMiguel Rodriguez
 

Ähnlich wie Managing PostgreSQL with PgCenter (20)

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
 
Broken Performance Tools
Broken Performance ToolsBroken Performance Tools
Broken Performance Tools
 
200.1,2-Capacity Planning
200.1,2-Capacity Planning200.1,2-Capacity Planning
200.1,2-Capacity Planning
 
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
 
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
 
Analyzing OS X Systems Performance with the USE Method
Analyzing OS X Systems Performance with the USE MethodAnalyzing OS X Systems Performance with the USE Method
Analyzing OS X Systems Performance with the USE Method
 
Monitoreo de MySQL y PostgreSQL con SQL
Monitoreo de MySQL y PostgreSQL con SQLMonitoreo de MySQL y PostgreSQL con SQL
Monitoreo de MySQL y PostgreSQL con SQL
 
제2회난공불락 오픈소스 세미나 커널튜닝
제2회난공불락 오픈소스 세미나 커널튜닝제2회난공불락 오픈소스 세미나 커널튜닝
제2회난공불락 오픈소스 세미나 커널튜닝
 
How to Diagnose Problems Quickly on Linux Servers
How to Diagnose Problems Quickly on Linux ServersHow to Diagnose Problems Quickly on Linux Servers
How to Diagnose Problems Quickly on Linux Servers
 
SOFA Tutorial
SOFA TutorialSOFA Tutorial
SOFA Tutorial
 
Performance tuning
Performance tuningPerformance tuning
Performance tuning
 
Clear cache memory
Clear cache memoryClear cache memory
Clear cache memory
 
Как понять, что происходит на сервере? / Александр Крижановский (NatSys Lab.,...
Как понять, что происходит на сервере? / Александр Крижановский (NatSys Lab.,...Как понять, что происходит на сервере? / Александр Крижановский (NatSys Lab.,...
Как понять, что происходит на сервере? / Александр Крижановский (NatSys Lab.,...
 
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
 
Servers and Processes: Behavior and Analysis
Servers and Processes: Behavior and AnalysisServers and Processes: Behavior and Analysis
Servers and Processes: Behavior and Analysis
 
The true story_of_hello_world
The true story_of_hello_worldThe true story_of_hello_world
The true story_of_hello_world
 
Guide to alfresco monitoring
Guide to alfresco monitoringGuide to alfresco monitoring
Guide to alfresco monitoring
 

Mehr von 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
 
Highload 2014. PostgreSQL: ups, DevOps.
Highload 2014. PostgreSQL: ups, DevOps.Highload 2014. PostgreSQL: ups, DevOps.
Highload 2014. PostgreSQL: ups, DevOps.Alexey Lesovsky
 

Mehr von Alexey Lesovsky (8)

Отладка и устранение проблем в 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
 
Highload 2014. PostgreSQL: ups, DevOps.
Highload 2014. PostgreSQL: ups, DevOps.Highload 2014. PostgreSQL: ups, DevOps.
Highload 2014. PostgreSQL: ups, DevOps.
 

Kürzlich hochgeladen

Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
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
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
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
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 

Kürzlich hochgeladen (20)

Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........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
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
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
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 

Managing PostgreSQL with PgCenter

  • 1. Managing PostgreSQL with pgCenter PgConf EU 2016, Estonia, Tallinn Alexey Lesovsky lesovsky@pgco.me
  • 2. I am a PostgreSQL DBA: ● Linux administration, internals; ● and PostgreSQL of course. Work in PostgreSQL-Consulting: ● Consulting, support, troubleshooting, profiling, training, etc... https://goo.gl/NYRFQV About me
  • 3. PostgreSQL statistics overview. PgCenter – quick overview. Management and troubleshoot with pgCenter. Outline
  • 4. + The most subsystems and objects have stats. + Getting stats is quite easy. – Stats are provided as counters. – No history or what happened X minutes ago? – No builtin tools, only psql and hand-made queries. PostgreSQL statistics
  • 5. Write Ahead Log Shared Buffers Buffers IO Autovacuum Workers Autovacuum Launcher Background Workers Indexes IO Query Execution Query Planning Client Backends Postmaster Tables IO Logger Process Stats Collector Logical Replication WAL Sender Process Archiver Process Background Writer Checkpointer Process Network Storage Recovery Process WAL Receiver Process Tables/Indexes Data Files pg_stat_all_tables pg_current_xlog_location pg_replication_slots pg_stat_replication pg_stat_archiver pg_stat_database_conflicts pg_buffercache pg_stat_database pg_stat_activity pg_stat_user_tables pg_stat_database pg_stat_bgwrier pgstattuplepg_table_size pg_database_size pg_index_size pg_stat_activity EXPLAIN pg_stat_statements pg_locks pg_stat_user_functions pg_stat_all_indexes pg_stat_database pg_statio_all_indexes pg_statio_all_tables pg_xlog_location_diff nicstat* iostat* pg_stat_kcache pg_stat_statements * system tools pg_stat_progress_vacuum pg_stat_wal_receiver pg_blocking_pids
  • 6. Written in the C, uses libpq and ncurses. Support PostgreSQL 9.x (9.0 ... 9.6). Linux only. Sources on Github. Packages: ● ALT Linux; ● RedHat/CentOS/Fedora (pgdg, epel-testing); ● Ubuntu (Launchpad); What is the pgCenter
  • 7. Top-like interface for viewing stats. System resource utilization (cpu, memory, storage, networking). PostgreSQL general utilization (connections, autovacuum, qps). Common admin tasks. Major features
  • 8. The same options as in the psql: ● pgcenter -h 127.0.0.1 -p 5432 -U postgres -d mydb ● pgcenter -U postgres mydb ● pgcenter mydb Environment variables: ● PGHOST, PGPORT, PGUSER, PGDATABASE, PGPASSWORD Connections file (~/.pgcenterrc). How to run pgCenter
  • 9. pgcenter: 2016-09-28 11:45:42, load average: 8.65, 8.80, 8.17 conn1 [ok]: 127.0.0.1:5432 postgres@postgres (ver: 9.6.0, up 00:29:28) %cpu: 26.5 us, 2.6 sy, 0.0 ni, 69.8 id, 1.1 wa, 0.0 hi, 0.0 si, 0.0 st activity: 25 total, 17 idle, 1 idle_in_xact, 7 active, 0 waiting, 0 others MiB mem: 30679 total, 258 free, 1130 used, 29291 buff/cached autovacuum: 1/8 workers/max, 0 manual, 0 wraparound, 00:08:15 vac_maxtime MiB swap: 5119 total, 5119 free, 0 used, 3/0 dirty/writeback statements: 0 stmt/s, 0.000 stmt_avgtime, 00:08:15 xact_maxtime datname commit rollback reads hits returned fetched inserts updates deletes conflicts deadlocks tmp_files tmp_bytes read_t write_t prod_db 1752 0 805 29173 197095 3504 1752 5256 0 0 0 0 0 13 0 appcast 832 0 183 12448 93215 1664 832 2496 0 0 0 0 0 2 0 template1 0 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 postgres 5 1 0 0 0 0 0 0 0 0 0 0 0 0 0 Interface overview
  • 10. pgcenter: 2016-09-28 11:45:42, load average: 8.65, 8.80, 8.17 conn1 [ok]: 127.0.0.1:5432 postgres@postgres (ver: 9.6.0, up 00:29:28) %cpu: 26.5 us, 2.6 sy, 0.0 ni, 69.8 id, 1.1 wa, 0.0 hi, 0.0 si, 0.0 st activity: 25 total, 17 idle, 1 idle_in_xact, 7 active, 0 waiting, 0 others MiB mem: 30679 total, 258 free, 1130 used, 29291 buff/cached autovacuum: 1/8 workers/max, 0 manual, 0 wraparound, 00:08:15 vac_maxtime MiB swap: 5119 total, 5119 free, 0 used, 3/0 dirty/writeback statements: 0 stmt/s, 0.000 stmt_avgtime, 00:08:15 xact_maxtime datname commit rollback reads hits returned fetched inserts updates deletes conflicts deadlocks tmp_files tmp_bytes read_t write_t prod_db 1752 0 805 29173 197095 3504 1752 5256 0 0 0 0 0 13 0 appcast 832 0 183 12448 93215 1664 832 2496 0 0 0 0 0 2 0 template1 0 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 postgres 5 1 0 0 0 0 0 0 0 0 0 0 0 0 0 Interface overview System metrics
  • 11. pgcenter: 2016-09-28 11:45:42, load average: 8.65, 8.80, 8.17 conn1 [ok]: 127.0.0.1:5432 postgres@postgres (ver: 9.6.0, up 00:29:28) %cpu: 26.5 us, 2.6 sy, 0.0 ni, 69.8 id, 1.1 wa, 0.0 hi, 0.0 si, 0.0 st activity: 25 total, 17 idle, 1 idle_in_xact, 7 active, 0 waiting, 0 others MiB mem: 30679 total, 258 free, 1130 used, 29291 buff/cached autovacuum: 1/8 workers/max, 0 manual, 0 wraparound, 00:08:15 vac_maxtime MiB swap: 5119 total, 5119 free, 0 used, 3/0 dirty/writeback statements: 0 stmt/s, 0.000 stmt_avgtime, 00:08:15 xact_maxtime datname commit rollback reads hits returned fetched inserts updates deletes conflicts deadlocks tmp_files tmp_bytes read_t write_t prod_db 1752 0 805 29173 197095 3504 1752 5256 0 0 0 0 0 13 0 appcast 832 0 183 12448 93215 1664 832 2496 0 0 0 0 0 2 0 template1 0 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 postgres 5 1 0 0 0 0 0 0 0 0 0 0 0 0 0 Interface overview System metrics PostgreSQL metrics
  • 12. pgcenter: 2016-09-28 11:45:42, load average: 8.65, 8.80, 8.17 conn1 [ok]: 127.0.0.1:5432 postgres@postgres (ver: 9.6.0, up 00:29:28) %cpu: 26.5 us, 2.6 sy, 0.0 ni, 69.8 id, 1.1 wa, 0.0 hi, 0.0 si, 0.0 st activity: 25 total, 17 idle, 1 idle_in_xact, 7 active, 0 waiting, 0 others MiB mem: 30679 total, 258 free, 1130 used, 29291 buff/cached autovacuum: 1/8 workers/max, 0 manual, 0 wraparound, 00:08:15 vac_maxtime MiB swap: 5119 total, 5119 free, 0 used, 3/0 dirty/writeback statements: 0 stmt/s, 0.000 stmt_avgtime, 00:08:15 xact_maxtime datname commit rollback reads hits returned fetched inserts updates deletes conflicts deadlocks tmp_files tmp_bytes read_t write_t prod_db 1752 0 805 29173 197095 3504 1752 5256 0 0 0 0 0 13 0 appcast 832 0 183 12448 93215 1664 832 2496 0 0 0 0 0 2 0 template1 0 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 postgres 5 1 0 0 0 0 0 0 0 0 0 0 0 0 0 Interface overview System metrics PostgreSQL metrics Statistics values
  • 13. pgcenter: 2016-09-28 11:45:42, load average: 8.65, 8.80, 8.17 conn1 [ok]: 127.0.0.1:5432 postgres@postgres (ver: 9.6.0, up 00:29:28) %cpu: 26.5 us, 2.6 sy, 0.0 ni, 69.8 id, 1.1 wa, 0.0 hi, 0.0 si, 0.0 st activity: 25 total, 17 idle, 1 idle_in_xact, 7 active, 0 waiting, 0 others MiB mem: 30679 total, 258 free, 1130 used, 29291 buff/cached autovacuum: 1/8 workers/max, 0 manual, 0 wraparound, 00:08:15 vac_maxtime MiB swap: 5119 total, 5119 free, 0 used, 3/0 dirty/writeback statements: 0 stmt/s, 0.000 stmt_avgtime, 00:08:15 xact_maxtime datname commit rollback reads hits returned fetched inserts updates deletes conflicts deadlocks tmp_files tmp_bytes read_t write_t prod_db 1752 0 805 29173 197095 3504 1752 5256 0 0 0 0 0 13 0 appcast 832 0 183 12448 93215 1664 832 2496 0 0 0 0 0 2 0 template1 0 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 postgres 5 1 0 0 0 0 0 0 0 0 0 0 0 0 0 Interface overview System metrics PostgreSQL metrics Statistics valuesAdditional information
  • 14. pgcenter: 2016-09-28 11:45:42, load average: 8.65, 8.80, 8.17 %cpu: 26.5 us, 2.6 sy, 0.0 ni, 69.8 id, 1.1 wa, 0.0 hi, 0.0 si, 0.0 st MiB mem: 30679 total, 258 free, 1130 used, 29291 buff/cached MiB swap: 5119 total, 5119 free, 0 used, 3/0 dirty/writeback Interface overview program name current time load average cpu usage memory usage swap usage
  • 15. pgcenter: 2016-09-28 11:45:42, load average: 8.65, 8.80, 8.17 %cpu: 26.5 us, 2.6 sy, 0.0 ni, 69.8 id, 1.1 wa, 0.0 hi, 0.0 si, 0.0 st MiB mem: 30679 total, 258 free, 1130 used, 29291 buff/cached MiB swap: 5119 total, 5119 free, 0 used, 3/0 dirty/writeback Interface overview program name current time load average cpu usage memory usage swap usage
  • 16. pgcenter: 2016-09-28 11:45:42, load average: 8.65, 8.80, 8.17 %cpu: 26.5 us, 2.6 sy, 0.0 ni, 69.8 id, 1.1 wa, 0.0 hi, 0.0 si, 0.0 st MiB mem: 30679 total, 258 free, 1130 used, 29291 buff/cached MiB swap: 5119 total, 5119 free, 0 used, 3/0 dirty/writeback Interface overview program name current time load average cpu usage memory usage swap usage
  • 17. pgcenter: 2016-09-28 11:45:42, load average: 8.65, 8.80, 8.17 %cpu: 26.5 us, 2.6 sy, 0.0 ni, 69.8 id, 1.1 wa, 0.0 hi, 0.0 si, 0.0 st MiB mem: 30679 total, 258 free, 1130 used, 29291 buff/cached MiB swap: 5119 total, 5119 free, 0 used, 3/0 dirty/writeback Interface overview program name current time load average cpu usage memory usage swap usage
  • 18. conn1 [ok]: 127.0.0.1:5432 postgres@postgres (ver: 9.6.0, up 00:29:28) activity: 25 total, 17 idle, 1 idle_in_xact, 7 active, 0 waiting, 0 others autovacuum: 1/8 workers/max, 0 manual, 0 wraparound, 00:08:15 vac_maxtime statements: 689 stmt/s, 1.857 stmt_avgtime, 00:00:01 xact_maxtime Interface overview tab number current connection postgres version connections vacuum operations queries/xact info postgres uptime
  • 19. conn1 [ok]: 127.0.0.1:5432 postgres@postgres (ver: 9.6.0, up 00:29:28) activity: 25 total, 17 idle, 1 idle_in_xact, 7 active, 0 waiting, 0 others autovacuum: 1/8 workers/max, 0 manual, 0 wraparound, 00:08:15 vac_maxtime statements: 689 stmt/s, 1.857 stmt_avgtime, 00:00:01 xact_maxtime Interface overview tab number current connection postgres version connections vacuum operations queries/xact info postgres uptime
  • 20. conn1 [ok]: 127.0.0.1:5432 postgres@postgres (ver: 9.6.0, up 00:29:28) activity: 25 total, 17 idle, 1 idle_in_xact, 7 active, 0 waiting, 0 others autovacuum: 1/8 workers/max, 0 manual, 0 wraparound, 00:08:15 vac_maxtime statements: 689 stmt/s, 1.857 stmt_avgtime, 00:00:01 xact_maxtime Interface overview tab number current connection postgres version connections vacuum operations queries/xact info postgres uptime
  • 21. conn1 [ok]: 127.0.0.1:5432 postgres@postgres (ver: 9.6.0, up 00:29:28) activity: 25 total, 17 idle, 1 idle_in_xact, 7 active, 0 waiting, 0 others autovacuum: 1/8 workers/max, 0 manual, 0 wraparound, 00:08:15 vac_maxtime statements: 689 stmt/s, 1.857 stmt_avgtime, 00:00:01 xact_maxtime Interface overview tab number current connection postgres version connections vacuum operations queries/xact info postgres uptime
  • 22. datname commit rollback reads hits returned fetched inserts updates > prod_db 1752 0 805 29173 197095 3504 1752 5256 > appcast 832 0 183 12448 93215 1664 832 2496 > template1 0 0 0 0 0 0 0 0 > template0 0 0 0 0 0 0 0 0 > Postgres 5 1 0 0 0 0 0 0 > Interface overview
  • 23. datname commit rollback reads hits returned fetched inserts updates > prod_db 1752 0 805 29173 197095 3504 1752 5256 > appcast 832 0 183 12448 93215 1664 832 2496 > template1 0 0 0 0 0 0 0 0 > template0 0 0 0 0 0 0 0 0 > Postgres 5 1 0 0 0 0 0 0 > Left, Right: change sort. F: Enable filter. /: Change sort order – desc or asc. Interface overview
  • 24. N: open new connection in a new tab Ctrl+D: close current tab. 1..8: switch between tabs. W: save opened connections settings to the connfile. General actions
  • 25. d: pg_stat_databases r: pg_stat_replication t: pg_stat_all_tables T: pg_statio_all_tables i: pg_stat_all_indexes, pg_statio_all_indexes f: pg_stat_user_functions a: pg_stat_activity v: pg_stat_progress_vacuum x: pg_stat_statements s: Relations size Available stats
  • 26. C: show config menu. E: edit config menu. R: reload postgres service. Admin tasks
  • 27. C: show config menu. E: edit config menu. R: reload postgres service. l: show log file. Admin tasks
  • 28. C: show config menu. E: edit config menu R: reload postgres service. l: show log file. -: сancel query using pid. _: terminate backend using pid. Del: cancel group of queries using mask. Shift+Del: terminate group of backends using mask. .: show current mask, >: set new mask. Admin tasks
  • 29. C: show config menu. E: edit config menu. R: reload postgres service. l: show log file. -: cancel query using pid. _: terminate backend using pid. Del: cancel group of queries using mask. Shift+Del: terminate group of backends using mask. .: show current mask, >: set new mask. p: open psql session. Admin tasks
  • 30. B: open iostat. I: open nicstat. L: tail postgres log (show the latest log lines). Additional Information
  • 31. B: open iostat. 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 sdb: 0.00 1.98 0.00 106.93 0.00 53.85 1031.33 141.19 1472.32 0.00 1472.32 100.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 sdb2: 0.00 1.98 0.00 106.93 0.00 53.85 1031.33 141.19 1472.32 0.00 1472.32 100.00 I: open nicstat. L: tail postgres log (show the latest log lines). Additional Information
  • 32. B: open iostat. I: open nicstat. Interface: rMbps wMbps rPk/s wPk/s rAvs wAvs IErr OErr Coll Sat %rUtil %wUtil %Util eth0: 592.33 7.29 52350.50 16897.03 1483.04 56.52 0.00 0.00 0.00 0.00 44.05 0.54 44.59 eth1: 119.04 1.85 10728.71 4290.10 1454.32 56.39 0.00 0.00 0.00 0.00 8.85 0.14 8.99 lo: 0.13 0.13 49.50 49.50 351.96 351.96 0.00 0.00 0.00 0.00 0.00 0.00 0.00 L: tail postgres log (show the latest log lines). Additional Information
  • 33. B: open iostat. I: open nicstat. L: tail postgres log (show the latest log lines). ERROR: cannot execute SELECT FOR UPDATE in a read-only transaction ERROR: cannot execute SELECT FOR UPDATE in a read-only transaction LOG: checkpoint starting: time LOG: checkpoint complete: wrote 40 buffers (0.0%); 0 transaction log file(s) added, 0 removed, 26 recycled; write=3.924 s, sync=0. ERROR: cannot execute SELECT FOR UPDATE in a read-only transaction Additional Information
  • 34. Troubleshoot: ● quick overview, resource utilization and postgresql activity; ● autovacuum issues; ● replication problems; ● database anomalies; ● tables, indexes and functions; ● where is the space? ● bad company; ● queries investigation. Troubleshoot
  • 35. Quick overview: ● run pgCenter; ● check resources usage (cpu, mem, disk, net); ● check the postgresql usage; ● make a plan what's next. Troubleshoot
  • 36. pgcenter: 2016-09-28 12:21:45, load average: 19.81, 5.15, 3.35 %cpu: 68.6 us, 5.5 sy, 0.0 ni, 15.1 id, 10.8 wa, 0.0 hi, 0.0 si, 0.0 st MiB mem: 30679 total, 1508 free, 1130 used, 28041 buff/cached MiB swap: 5119 total, 552 free, 4567 used, 834/198 dirty/writeback Troubleshoot
  • 37. pgcenter: 2016-09-28 12:21:45, load average: 19.81, 5.15, 3.35 %cpu: 68.6 us, 5.5 sy, 0.0 ni, 15.1 id, 10.8 wa, 0.0 hi, 0.0 si, 0.0 st MiB mem: 30679 total, 1508 free, 1130 used, 28041 buff/cached MiB swap: 5119 total, 552 free, 4567 used, 834/198 dirty/writeback load average? – check cpu/disks usage. us – check queries/activity. sy, si, hi – check system/kernel/hardware. wa – check queries, disks activity. mem/swap – revise shared_buffers/work_mem. dirty/writeback – write activity, disks utilization. Troubleshoot
  • 38. PostgreSQL general state: ● too many connections; ● too many bad connections (waiting, idle_in_xact); ● too many vacuums, long vacuum; ● too many queries, long transactions/queries; Troubleshoot
  • 39. conn1 [ok]: 127.0.0.1:5432 postgres@postgres (ver: 9.6.0, up 05:02:50) activity: 44 total, 2 idle, 2 idle_in_xact, 9 active, 31 waiting, 0 others autovacuum: 6/8 workers/max, 0 manual, 6 wraparound, 02:13:02 vac_maxtime statements: 172 stmt/s, 5.390 stmt_avgtime, 00:18:37 xact_maxtime Troubleshoot
  • 40. conn1 [ok]: 127.0.0.1:5432 postgres@postgres (ver: 9.6.0, up 05:02:50) activity: 44 total, 2 idle, 2 idle_in_xact, 9 active, 31 waiting, 0 others autovacuum: 6/8 workers/max, 0 manual, 6 wraparound, 02:13:02 vac_maxtime statements: 172 stmt/s, 5.390 stmt_avgtime, 00:18:37 xact_maxtime too many active – check activity. idle in transactions, waiting – check activity, cancel or terminate that. what about autovacuum worker limit? – increase the limit, play with cost parameters. check pg_stat_progress_vacuum, disks utilization. long transactions – cancel or terminate. Troubleshoot
  • 41. Replication problems: ● replication lag – queries with different results; ● network utilization, errors; ● disk utilization, bandwidth. Troubleshoot
  • 42. client user name state mode pending write flush replay total_lag 10.13.0.5 replica walreceiver streaming async 256 0 0 227754 228009 10.13.0.7 replica walreceiver streaming async 1248558 0 0 514 1249072 10.13.0.6 replica walreceiver streaming async 0 0 0 64 64 Troubleshoot
  • 43. client user name state mode pending write flush replay total_lag 10.13.0.5 replica walreceiver streaming async 256 0 0 227754 228009 10.13.0.7 replica walreceiver streaming async 1248558 0 0 514 1249072 10.13.0.6 replica walreceiver streaming async 0 0 0 64 64 high pending – busy master/network. high write/flush/replay – busy standby, long running queries. Troubleshoot
  • 44. Database anomalies: ● rollbacks; ● deadlocks; ● recovery conflicts; ● temporary files. Troubleshoot
  • 45. datname commit rollback reads hits returned fetched inserts updates deletes conflicts deadlocks tmp_files tmp_bytes read_t write_t pgbench 11845 0 0 61663 11845 0 0 11845 0 0 0 4 85725 0 0 staging 1854 10 0 128 1844 0 1844 0 0 0 0 0 0 0 0 template1 0 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 Postgres 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Troubleshoot
  • 46. datname commit rollback reads hits returned fetched inserts updates deletes conflicts deadlocks tmp_files tmp_bytes read_t write_t pgbench 11845 0 0 61663 11845 0 0 11845 0 0 0 4 85725 0 0 staging 1854 10 0 128 1844 0 1844 0 0 0 0 0 0 0 0 template1 0 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 Postgres 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 rollbacks – check postgres and application logs for errors. deadlocks – check postgres log, review pg_locks. conflicts – check pg_stat_database_conflicts, raise delays, enable feedback. temporary files – check logs, pg_stat_statements, work_mem (carefully). Troubleshoot
  • 47. Tables activity: ● sequential scans; ● abnormal activity; Troubleshoot
  • 48. relation seq_scan seq_read idx_scan idx_fetch inserts updates deletes hot_updates live dead public.job_stats 94 116090 0 0 0 0 0 0 0 0 public.feed_settings 10924 10924 0 0 0 10924 0 10924 0 7 public.feed_actions 0 0 35 1275 0 68 3 0 0 3 public.job_boards 0 0 0 0 0 0 0 0 0 0 Troubleshoot
  • 49. relation seq_scan seq_read idx_scan idx_fetch inserts updates deletes hot_updates live dead public.job_stats 94 116090 0 0 0 0 0 0 0 0 public.feed_settings 924 924 0 0 0 924 0 924 0 7 public.feed_actions 0 0 35 1275 0 68 3 0 0 3 public.job_boards 0 0 0 0 0 0 0 0 0 0 sequential scans – no index or broken planner stats. abnormal activity – too many CRUD, check pg_statio_all_tables. Troubleshoot
  • 50. Index activity: ● unused indexes; Troubleshoot
  • 51. relation index idx_scan idx_tup_read idx_tup_fetch idx_read idx_hit public.job_bodies job_bodies_pkey 850 850 850 0 14560 public.job_bodies job_bodies_refcount_idx 850 880 850 0 14960 public.job_bodies job_bodies_reftype_idx 170 255 170 1136 7024 public.job_bodies job_bodies_spc2_idx 0 0 0 0 0 public.job_bodies job_bodies_spc5_idx 0 0 0 0 0 Troubleshoot
  • 52. relation index idx_scan idx_tup_read idx_tup_fetch idx_read idx_hit public.job_bodies job_bodies_pkey 850 850 850 0 14560 public.job_bodies job_bodies_refcount_idx 850 880 850 0 14960 public.job_bodies job_bodies_reftype_idx 170 255 170 1136 7024 public.job_bodies job_bodies_spc2_idx 0 0 0 0 0 public.job_bodies job_bodies_spc5_idx 0 0 0 0 0 zero idx_scan – unused indexes; tip: before drop them, check its usage on standbys. Troubleshoot
  • 53. Functions usage: ● long running functions; ● run psql, edit function with ef funcname. Troubleshoot
  • 54. Where is the space Postgres ? ● check tables sizes (with and without indexes); ● check tables size changes; ● use filters to see interesting tables. Troubleshoot
  • 55. relation total_size rel_size idx_size total_change rel_change idx_change public.job_bodies 7656200 6557568 1098632 312 260 58 public.job_stats_20161004 1629232 1285764 343468 37928 29920 8008 public.rules 3000 2744 256 0 0 0 public.resumes 384 224 160 0 0 0 public.versions 112 40 72 0 0 0 Troubleshoot
  • 56. Bad company: ● long running queries or idle transactions; ● waiting queries/transactions; ● cancel queries or terminate backends using pid or mask; ● change age threshold to hide unwanted things. Troubleshoot
  • 57. pid cl_addr cl_port datname usename state wait_etype wait_event xact_age query_age change_age query 6942 -1 shopdb shop_app active Lock transactionid 00:10:14 00:00:17 00:00:17 update > 6930 -1 shopdb shop_app active 00:08:17 00:00:12 00:00:12 update > 3429 -1 shopdb shop_app active Lock transactionid 00:07:01 00:00:02 00:00:00 update > 3857 -1 shopdb shop_app active 00:00:00 00:00:00 00:00:00 select > 5781 -1 shopdb shop_bg active 00:03:29 00:00:01 00:00:01 select > 6901 -1 shopdb shop_bg active 00:01:10 00:00:01 00:00:01 select > Troubleshoot
  • 58. pid cl_addr cl_port datname usename state wait_etype wait_event xact_age query_age change_age query 6942 -1 shopdb shop_app active Lock transactionid 00:10:14 00:00:17 00:00:17 update > 6930 -1 shopdb shop_app active 00:08:17 00:00:12 00:00:12 update > 3429 -1 shopdb shop_app active Lock transactionid 00:07:01 00:00:02 00:00:00 update > 3857 -1 shopdb shop_app active 00:00:00 00:00:00 00:00:00 select > 5781 -1 shopdb shop_bg active 00:03:29 00:00:01 00:00:01 select > 6901 -1 shopdb shop_bg active 00:01:10 00:00:01 00:00:01 select > idle in transaction, waiting – cancel or terminate. use age thresholds and filters. Troubleshoot
  • 59. Query investigation: ● cpu- or disk hog queries; ● most called queries; ● queries doing a lot of IO; ● pg_stat_statements; ● query reports; ● looking for a query example; ● run psql and EXPLAIN ANALYZE query; ● rewrite a query, build an index, move a query to the standby, blame developers... Troubleshoot
  • 60. 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:56:05 00:00:00 00:00:00 00:56:05 254 0 0 254 10790 e19c70cd44 update > postgres pgbench 00:00:32 00:00:00 00:00:00 00:00:32 4 0 0 4 10790 cfc329b478 commit; postgres pgbench 00:00:28 00:00:00 00:00:00 00:00:28 4 0 0 4 10790 731392f8ec begin; postgres pgbench 00:35:03 00:14:01 00:00:00 00:21:02 85 22 0 107 1587 a357c10e55 select > postgres pgbench 00:22:27 00:08:15 00:00:00 00:14:12 51 10 0 61 854 4db337810e update > postgres pgbench 00:07:23 00:00:00 00:00:00 00:07:23 11 0 0 11 59 6acc738af9 select > Troubleshoot
  • 61. summary: total_time: 01:03:47, cpu_time: 00:59:38, io_time: 00:04:09 (ALL: 100.00%, CPU: 93.47%, IO: 6.53%), total queries: 258,798,086 query info: usename: streamcast, datname: outpost, calls (relative to all queries): 86,250,226 (33.33%), rows (relative to all queries): 86,250,226 (94.46%), total time (relative to all queries): 00:58:14 (ALL: 91.3%, CPU: 97.7%, IO: 0.0%), average time (only for this query): 0.04ms, cpu_time: 0.04ms, io_time: 0.00ms, (ALL: 100.0%, CPU: 100.0%, IO: 0.0%), query text (id: 14a58a3b9f): SELECT tags.tg_id FROM tags WHERE tags.id IN (?, ?, ?) AND (id NOT IN (?)) GROUP BY id HAVING count(distinct tg_id) > ? LIMIT ? Troubleshoot
  • 62. pgCenter has many features but: ● psql is always available – 'p' hotkey. ● use the help – 'h' hotkey. In the end
  • 63. pgCenter is useful: ● to check what's going on; ● for quick overview; ● to make simple admin operations; ● to manage postgres easier and faster (I hope). In the end
  • 64. Alexey Lesovsky lesovsky@pgco.me PostgreSQL–Consulting: Data maintenance as its best. http://postgresql-consulting.com Questions?