SlideShare a Scribd company logo
1 of 68
Download to read offline
Способы диагностики
PostgreSQL
Владимир Бородин Ильдус Курбангалиев
Где взять презентацию?
yadi.sk/d/KSIYFBiyhis2s
2
Взрыв мониторинга
Р. Чернышевский и А. Герцен
Кто виноват?
Что делать?
Во что упёрлись?
Системные ресурсы:
〉 Процессор/память/диски/сеть
Внутренние процессы базы:
〉 Heavy-weight locks
〉 Всё остальное
5
Процессор
6
Диск
7
Диск
8
Сеть
9
Память
〉 Swap
〉 OOM
10
Heavy-weight locks
11
Heavy-weight locks
https://wiki.postgresql.org/wiki/Lock_dependency_information
12
13
pg_stat_statements
14
pg_stat_kcache
15
16
17
SELECT datname, queryid, round(total_time::numeric, 2) AS total_time, calls,
pg_size_pretty((shared_blks_hit+shared_blks_read)*8192 - reads) AS memory_hit,
pg_size_pretty(reads) AS disk_read, pg_size_pretty(writes) AS disk_write,
round(user_time::numeric, 2) AS user_time, round(system_time::numeric, 2) AS
system_time
FROM pg_stat_statements s
JOIN pg_stat_kcache() k USING (userid, dbid, queryid)
JOIN pg_database d ON s.dbid = d.oid
WHERE datname != 'postgres' AND datname NOT LIKE 'template%'
ORDER BY total_time DESC LIMIT 10;
18
SELECT datname, queryid, round(total_time::numeric, 2) AS total_time, calls,
pg_size_pretty((shared_blks_hit+shared_blks_read)*8192 - reads) AS memory_hit,
pg_size_pretty(reads) AS disk_read, pg_size_pretty(writes) AS disk_write,
round(user_time::numeric, 2) AS user_time, round(system_time::numeric, 2) AS
system_time
FROM pg_stat_statements s
JOIN pg_stat_kcache() k USING (userid, dbid, queryid)
JOIN pg_database d ON s.dbid = d.oid
WHERE datname != 'postgres' AND datname NOT LIKE 'template%'
ORDER BY total_time DESC LIMIT 10;
19
Проблемы сложнее
Сильное увеличение нагрузки на I/O
приводит к потреблению всего
процессорного времени в system
21
Perf
22
Perf
23
Кобб
We need to go deeper
SystemTap
〉 Можно посмотреть очень многое
〉 Требует пересборки PostgreSQL
〉 Быстро stap не написать, а иметь готовые на все случаи
жизни не получится
〉 Не стоит использовать в бою
https://simply.name/postgresql-and-systemtap.html
25
GDB
# yum -y install postgresql94-debuginfo
# cat /usr/local/yandex/gdb_bt_cmd
bt
# fgrep gdb /usr/bin/bt
cmd = 'gdb -batch -x /usr/local/yandex/gdb_bt_cmd
/usr/pgsql-9.4/bin/postgres %d' % pid
#
26
GDB
#0 0x00007fdacd68bf27 in semop () from /lib64/libc.so.6
#1 0x000000000061fe27 in PGSemaphoreLock (sema=0x7fdbe02f84b0, interruptOK=0 '000')
at pg_sema.c:421
#2 0x00000000006769ba in LWLockAcquireCommon (l=0x7fdacf400560, mode=LW_SHARED) at
lwlock.c:626
#3 LWLockAcquire (l=0x7fdacf400560, mode=LW_SHARED) at lwlock.c:467
#4 0x000000000065db61 in BufferAlloc (smgr=0x1b30770, relpersistence=112 'p',
forkNum=MAIN_FORKNUM, blockNum=21261, mode=RBM_NORMAL, strategy=0x0,
hit=0x7fff20e86eff "") at bufmgr.c:591
#5 ReadBuffer_common (smgr=0x1b30770, relpersistence=112 'p', forkNum=MAIN_FORKNUM,
blockNum=21261, mode=RBM_NORMAL, strategy=0x0, hit=0x7fff20e86eff "") at bufmgr.c:340
#6 0x000000000065e55e in ReadBufferExtended (reln=0x7fdacf08ede0,
forkNum=MAIN_FORKNUM, blockNum=21261, mode=<value optimized out>, strategy=<value
27
GDB
〉 https://github.com/dev1ant/misc/blob/master/bt
〉 Не складывает production
〉 Пакеты *-debuginfo есть во всех репозиториях страны
〉 С точностью до строчки кода понятно, что происходит
28
Отладка проблемы
Пример 1
30
Пример 1
31
Пример 1
ALTER INDEX mail.i_box_uid_lids SET (FASTUPDATE=OFF);
postgresql.org/docs/current/static/gin-implementation.html
32
Пример 2
33
Пример 2
34
Пример 2
0x00007fb53eebfe97 in semop () from /lib64/libc.so.6
#0 0x00007fb53eebfe97 in semop () from /lib64/libc.so.6
#1 0x000000000061fe27 in PGSemaphoreLock (sema=0x7fb757757430, interruptOK=0
'000') at pg_sema.c:421
#2 0x00000000006769ba in LWLockAcquireCommon (l=0x7fb540c000a0,
mode=LW_EXCLUSIVE) at lwlock.c:626
#3 LWLockAcquire (l=0x7fb540c000a0, mode=LW_EXCLUSIVE) at lwlock.c:467
#4 0x000000000065ebde in StrategyGetBuffer (strategy=0x0,
lock_held=0x7fffb44cdebe "001001030001") at freelist.c:134
#5 0x000000000065de25 in BufferAlloc (smgr=0x2a34090, relpersistence=112 'p',
forkNum=MAIN_FORKNUM, blockNum=1072861, mode=RBM_NORMAL, strategy=0x0,
hit=0x7fffb44cdf2f "") at bufmgr.c:648
35
Пример 2
# echo never > /sys/kernel/mm/redhat_transparent_hugepage/enabled
postgresql.org/message-id/55356496.9060607@aule.net
36
Пример 3
37
Пример 3
38
Пример 3
# grep '^#4 ' /tmp/bt | awk '{print $2, $4, $NF}' | sort
| uniq -c | sort -rn
126 0x000000000065db61 BufferAlloc bufmgr.c:591
67 0x000000000065e03a BufferAlloc bufmgr.c:760
43 0x00000000005c8c3b pq_getbyte pqcomm.c:899
39 0x000000000065dd93 BufferAlloc bufmgr.c:765
6 0x00000000004b52bb RecordTransactionCommit
xact.c:1194
4 0x000000000065da0e ReadBuffer_common bufmgr.c:476
1 ReadBuffer_common relpersistence=112 bufmgr.c:340
1 exec_eval_expr expr=0x166e908, pl_exec.c:4796
39
Пример 3
〉 Уменьшение shared_buffers
〉 src/include/storage/lwlock.h
-#define NUM_BUFFER_PARTITIONS 16
+#define NUM_BUFFER_PARTITIONS 128
〉 git.postgresql.org/pg/commitdiff/d72731a7
〉 git.postgresql.org/pg/commitdiff/1dcfb8da
〉 wiki.postgresql.org/wiki/Shared_Buffer_Improvements
40
Пример 4
41
https://clck.ru/9Xffq
Пример 4
42
Пример 4
0x00007f54a71444c0 in __read_nocancel () from /lib64/libc.so.6
#0 0x00007f54a71444c0 in __read_nocancel () from /lib64/libc.so.6
#1 0x000000000065d2f5 in FileRead (file=<value optimized out>, buffer=0x7f53ac0dba20 ";9",
amount=8192) at fd.c:1286
#2 0x000000000067acad in mdread (reln=<value optimized out>, forknum=<value optimized out>,
blocknum=12063036, buffer=0x7f53ac0dba20 ";9") at md.c:679
#3 0x0000000000659b4e in ReadBuffer_common (smgr=<value optimized out>, relpersistence=112 'p',
forkNum=MAIN_FORKNUM, blockNum=12063036, mode=RBM_NORMAL_NO_LOG, strategy=0x0, hit=0x7fff898a912f "")
at bu
fmgr.c:476
#4 0x000000000065a61b in ReadBufferWithoutRelcache (rnode=..., forkNum=MAIN_FORKNUM,
blockNum=12063036, mode=<value optimized out>, strategy=<value optimized out>) at bufmgr.c:287
#5 0x00000000004cfb78 in XLogReadBufferExtended (rnode=..., forknum=MAIN_FORKNUM, blkno=12063036,
mode=RBM_NORMAL_NO_LOG) at xlogutils.c:324
#6 0x00000000004a3651 in btree_xlog_vacuum (lsn=71744181579864, record=0x1e49dc0) at nbtxlog.c:522
#7 btree_redo (lsn=71744181579864, record=0x1e49dc0) at nbtxlog.c:1144
#8 0x00000000004c903a in StartupXLOG () at xlog.c:6827
#9 0x000000000062f8bf in StartupProcessMain () at startup.c:224
#10 0x00000000004d3e9a in AuxiliaryProcessMain (argc=2, argv=0x7fff898a98a0) at bootstrap.c:416
#11 0x000000000062a99c in StartChildProcess (type=StartupProcess) at postmaster.c:5146
43
Пример 4
〉 https://clck.ru/9Xfx6
〉 https://commitfest.postgresql.org/5/233/
〉 Секционирование больших insert-only таблиц
44
Светлое будущее
Какие ожидания нужно мониторить?
〉 Locks (heavyweight)
〉 LWLocks (lightweight locks)
〉 Latch
〉 Network
〉 Storage (IO)
46
Какие недостатки у текущих инструментов?
〉 Часто нельзя использовать в production
〉 Они разрозненные и их много
〉 Тяжело настраиваются и устанавливаются
47
pg_stat_wait
〉 Profiling
〉 Трассировка в файл
〉 История ожиданий
48
Требования
〉 Минимальный overhead
〉 Возможность просмотра в онлайн-режиме
〉 Высокая точность
〉 Один инструмент для всех типов ожиданий
49
pg_stat_wait_profile
50
b1=# SELECT * FROM pg_stat_wait_profile ORDER BY wait_count DESC;
pid | class_id | class_name | event_id | event_name | wait_time | wait_count
-------+----------+------------+----------+---------------------+-------------+------------
10781 | 4 | Latch | 0 | Latch | 90939504509 | 18217
11085 | 4 | Latch | 0 | Latch | 51834 | 9209
11085 | 5 | Network | 1 | WRITE | 65355 | 576
11085 | 3 | Storage | 0 | READ | 2273 | 188
11085 | 5 | Network | 0 | READ | 90932631592 | 93
10779 | 3 | Storage | 1 | WRITE | 1440 | 65
10782 | 3 | Storage | 0 | READ | 1040 | 43
10780 | 3 | Storage | 1 | WRITE | 367 | 15
5829 | 5 | Network | 1 | WRITE | 11 | 3
6025 | 5 | Network | 1 | WRITE | 10 | 2
11085 | 1 | LWLocks | 41 | BufferPartitionLock | 1355 | 2
11085 | 3 | Storage | 1 | WRITE | 9 | 2
5829 | 5 | Network | 0 | READ | 462 | 2
pg_stat_wait_history
51
b1=# SELECT * FROM pg_stat_wait_history WHERE class_id != 4 LIMIT 2;
pid | sample_ts | class_id | class_name | event_id | event_name | wait_time |
p1 | p2 | p3 | p4 | p5
-------+-------------------------------+----------+------------+----------+------------+-----------
+------+-------+-------+----+----
11085 | 2015-07-10 10:37:41.321489-04 | 3 | Storage | 1 | WRITE | 3520 |
1663 | 16384 | 16458 | 0 | 0
11085 | 2015-07-10 10:37:09.390442-04 | 5 | Network | 1 | WRITE | 7815 |
0 | 0 | 0 | 0 | 0
〉class_id - класс ожидания (lock, lwlock, io, latch, or network)
〉event_id - событие
〉p1 .. p5 - параметры ожидания
Трассировка
Даёт большой overhead, используйте только для отдельных сессий
terminal 1: $ psql b1
terminal 2:
$ ps ax | grep postgres
<…>
11085 ? Ss 0:00 postgres: postgres b1 [local] idle
$ psql b1 -c "select pg_start_trace(11085, '/tmp/f.trace')"
terminal 1:
b1=# CREATE TABLE t1 AS SELECT i, i*10 AS i1 FROM generate_series(1,10) i;
SELECT 10
52
Трассировка
terminal 2:
$ tail -f /tmp/f.trace
stop 2015-07-10 10:03:35.603458-04 Network
start 2015-07-10 10:03:35.603464-04 Network READ 0 0 0 0 0
stop 2015-07-10 10:03:44.099587-04 Network
start 2015-07-10 10:03:44.100401-04 Storage READ 1663 16384 1259 2 0
stop 2015-07-10 10:03:44.100424-04 Storage
start 2015-07-10 10:03:44.102549-04 Network WRITE 0 0 0 0 0
stop 2015-07-10 10:03:44.102573-04 Network
start 2015-07-10 10:03:44.102582-04 Network READ 0 0 0 0 0
stop 2015-07-10 10:05:33.029975-04 Network
start 2015-07-10 10:05:33.030205-04 Storage READ 1663 16384 2691 0 28
stop 2015-07-10 10:05:33.030233-04 Storage
start 2015-07-10 10:05:33.030246-04 Storage READ 1663 16384 1255 0 50
stop 2015-07-10 10:05:33.03026-04 Storage
53
54
Backend
Backend
Backend
Collector
Shared memory
ProcArray
History
Current view
History view
Profile view
Как устроен pg_stat_wait
Profile per wait
Profile per wait
Profile per wait
Сбор истории
55
Backend Backend Backend
ProcArray
Collector
Overhead
Тестовая конфигурация:
〉Intel(R) Xeon(R) CPU X5675@3.07GHz, 24 cores
〉RAM 24 GB
〉pgbench -S 500 ~ 1.6 Gb
Избегаем влияния дисковой подсистемы:
〉fsync off
〉tmpfs
56
Monitoring off
[ildus@1-i-kurbangaliev postgrespro]$ pgbench -S b1 -c 96 -j 4 -T 300
starting vacuum...end.
transaction type: SELECT only
scaling factor: 500
query mode: simple
number of clients: 96
number of threads: 4
duration: 300 s
number of transactions actually processed: 39349816
latency average: 0.732 ms
tps = 131130.859559 (including connections establishing)
tps = 131153.752204 (excluding connections establishing)
57
Monitoring on
[ildus@1-i-kurbangaliev postgrespro]$ pgbench -S b1 -c 96 -j 4 -T 300
starting vacuum...end.
transaction type: SELECT only
scaling factor: 500
query mode: simple
number of clients: 96
number of threads: 4
duration: 300 s
number of transactions actually processed: 39172607
latency average: 0.735 ms
tps = 130574.626755 (including connections establishing)
tps = 130600.767440 (excluding connections establishing)
58
Open source
〉 https://github.com/postgrespro/postgres
〉 https://clck.ru/9XsnG
〉 https://clck.ru/9XsnE
59
Немного примеров
Было
0x00007f10e01d4f27 in semop () from /lib64/libc.so.6
#0 0x00007f10e01d4f27 in semop () from /lib64/libc.so.6
#1 0x000000000061fe27 in PGSemaphoreLock (sema=0x7f11f2d4f430, interruptOK=0 '000') at
pg_sema.c:421
#2 0x00000000006769ba in LWLockAcquireCommon (l=0x7f10e1e00120, mode=LW_EXCLUSIVE) at
lwlock.c:626
#3 LWLockAcquire (l=0x7f10e1e00120, mode=LW_EXCLUSIVE) at lwlock.c:467
#4 0x0000000000667862 in ProcArrayEndTransaction (proc=0x7f11f2d4f420, latestXid=182562881)
at procarray.c:404
#5 0x00000000004b579b in CommitTransaction () at xact.c:1957
#6 0x00000000004b6ae5 in CommitTransactionCommand () at xact.c:2727
#7 0x00000000006819d9 in finish_xact_command () at postgres.c:2437
#8 0x0000000000684f05 in PostgresMain (argc=<value optimized out>, argv=<value optimized
out>, dbname=0x21e1a70 "xivadb", username=<value optimized out>) at postgres.c:4270
#9 0x0000000000632d7d in BackendRun (argc=<value optimized out>, argv=<value optimized out>)
at postmaster.c:4155
#10 BackendStartup (argc=<value optimized out>, argv=<value optimized out>) at postmaster.c:
3829
61
Стало
62
63
64
65
66
Вопросы?
Владимир Бородин
Системный администратор
Контакты
d0uble@yandex-team.ru
Ильдус Курбангалиев
Разработчик
@man_brain
i.kurbangaliev@postgrespro.ru

More Related Content

What's hot

PostgreSQL na EXT4, XFS, BTRFS a ZFS / FOSDEM PgDay 2016
PostgreSQL na EXT4, XFS, BTRFS a ZFS / FOSDEM PgDay 2016PostgreSQL na EXT4, XFS, BTRFS a ZFS / FOSDEM PgDay 2016
PostgreSQL na EXT4, XFS, BTRFS a ZFS / FOSDEM PgDay 2016Tomas Vondra
 
Postgres-BDR with Google Cloud Platform
Postgres-BDR with Google Cloud PlatformPostgres-BDR with Google Cloud Platform
Postgres-BDR with Google Cloud PlatformSungJae Yun
 
Add a bit of ACID to Cassandra. Cassandra Summit EU 2014
Add a bit of ACID to Cassandra. Cassandra Summit EU 2014Add a bit of ACID to Cassandra. Cassandra Summit EU 2014
Add a bit of ACID to Cassandra. Cassandra Summit EU 2014odnoklassniki.ru
 
MySQL Tokudb engine benchmark
MySQL Tokudb engine benchmarkMySQL Tokudb engine benchmark
MySQL Tokudb engine benchmarkLouis liu
 
Open Source SQL databases enters millions queries per second era
Open Source SQL databases enters millions queries per second eraOpen Source SQL databases enters millions queries per second era
Open Source SQL databases enters millions queries per second eraSveta Smirnova
 
Мастер-класс "Логическая репликация и Avito" / Константин Евтеев, Михаил Тюр...
Мастер-класс "Логическая репликация и Avito" / Константин Евтеев,  Михаил Тюр...Мастер-класс "Логическая репликация и Avito" / Константин Евтеев,  Михаил Тюр...
Мастер-класс "Логическая репликация и Avito" / Константин Евтеев, Михаил Тюр...Ontico
 
Recent my sql_performance Test detail
Recent my sql_performance Test detailRecent my sql_performance Test detail
Recent my sql_performance Test detailLouis liu
 
REDIS intro and how to use redis
REDIS intro and how to use redisREDIS intro and how to use redis
REDIS intro and how to use redisKris Jeong
 
PostgreSQL on EXT4, XFS, BTRFS and ZFS
PostgreSQL on EXT4, XFS, BTRFS and ZFSPostgreSQL on EXT4, XFS, BTRFS and ZFS
PostgreSQL on EXT4, XFS, BTRFS and ZFSTomas Vondra
 
Oracle cluster installation with grid and iscsi
Oracle cluster  installation with grid and iscsiOracle cluster  installation with grid and iscsi
Oracle cluster installation with grid and iscsiChanaka Lasantha
 
Oracle cluster installation with grid and nfs
Oracle cluster  installation with grid and nfsOracle cluster  installation with grid and nfs
Oracle cluster installation with grid and nfsChanaka Lasantha
 
My sql fabric ha and sharding solutions
My sql fabric ha and sharding solutionsMy sql fabric ha and sharding solutions
My sql fabric ha and sharding solutionsLouis liu
 
GitLab PostgresMortem: Lessons Learned
GitLab PostgresMortem: Lessons LearnedGitLab PostgresMortem: Lessons Learned
GitLab PostgresMortem: Lessons LearnedAlexey Lesovsky
 
Cpu高效编程技术
Cpu高效编程技术Cpu高效编程技术
Cpu高效编程技术Feng Yu
 
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
 
MyAWR another mysql awr
MyAWR another mysql awrMyAWR another mysql awr
MyAWR another mysql awrLouis liu
 
Nvmfs benchmark
Nvmfs benchmarkNvmfs benchmark
Nvmfs benchmarkLouis liu
 
Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Alexey Lesovsky
 

What's hot (20)

PostgreSQL na EXT4, XFS, BTRFS a ZFS / FOSDEM PgDay 2016
PostgreSQL na EXT4, XFS, BTRFS a ZFS / FOSDEM PgDay 2016PostgreSQL na EXT4, XFS, BTRFS a ZFS / FOSDEM PgDay 2016
PostgreSQL na EXT4, XFS, BTRFS a ZFS / FOSDEM PgDay 2016
 
Postgres-BDR with Google Cloud Platform
Postgres-BDR with Google Cloud PlatformPostgres-BDR with Google Cloud Platform
Postgres-BDR with Google Cloud Platform
 
Add a bit of ACID to Cassandra. Cassandra Summit EU 2014
Add a bit of ACID to Cassandra. Cassandra Summit EU 2014Add a bit of ACID to Cassandra. Cassandra Summit EU 2014
Add a bit of ACID to Cassandra. Cassandra Summit EU 2014
 
MySQL Tokudb engine benchmark
MySQL Tokudb engine benchmarkMySQL Tokudb engine benchmark
MySQL Tokudb engine benchmark
 
Open Source SQL databases enters millions queries per second era
Open Source SQL databases enters millions queries per second eraOpen Source SQL databases enters millions queries per second era
Open Source SQL databases enters millions queries per second era
 
Мастер-класс "Логическая репликация и Avito" / Константин Евтеев, Михаил Тюр...
Мастер-класс "Логическая репликация и Avito" / Константин Евтеев,  Михаил Тюр...Мастер-класс "Логическая репликация и Avito" / Константин Евтеев,  Михаил Тюр...
Мастер-класс "Логическая репликация и Avito" / Константин Евтеев, Михаил Тюр...
 
Recent my sql_performance Test detail
Recent my sql_performance Test detailRecent my sql_performance Test detail
Recent my sql_performance Test detail
 
Haproxy - zastosowania
Haproxy - zastosowaniaHaproxy - zastosowania
Haproxy - zastosowania
 
REDIS intro and how to use redis
REDIS intro and how to use redisREDIS intro and how to use redis
REDIS intro and how to use redis
 
PostgreSQL on EXT4, XFS, BTRFS and ZFS
PostgreSQL on EXT4, XFS, BTRFS and ZFSPostgreSQL on EXT4, XFS, BTRFS and ZFS
PostgreSQL on EXT4, XFS, BTRFS and ZFS
 
Oracle cluster installation with grid and iscsi
Oracle cluster  installation with grid and iscsiOracle cluster  installation with grid and iscsi
Oracle cluster installation with grid and iscsi
 
Oracle cluster installation with grid and nfs
Oracle cluster  installation with grid and nfsOracle cluster  installation with grid and nfs
Oracle cluster installation with grid and nfs
 
My sql fabric ha and sharding solutions
My sql fabric ha and sharding solutionsMy sql fabric ha and sharding solutions
My sql fabric ha and sharding solutions
 
GitLab PostgresMortem: Lessons Learned
GitLab PostgresMortem: Lessons LearnedGitLab PostgresMortem: Lessons Learned
GitLab PostgresMortem: Lessons Learned
 
Cpu高效编程技术
Cpu高效编程技术Cpu高效编程技术
Cpu高效编程技术
 
MongoDB Shard Cluster
MongoDB Shard ClusterMongoDB Shard Cluster
MongoDB Shard Cluster
 
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...
 
MyAWR another mysql awr
MyAWR another mysql awrMyAWR another mysql awr
MyAWR another mysql awr
 
Nvmfs benchmark
Nvmfs benchmarkNvmfs benchmark
Nvmfs benchmark
 
Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.
 

Viewers also liked

История небольшого успеха с PostgreSQL
История небольшого успеха с PostgreSQLИстория небольшого успеха с PostgreSQL
История небольшого успеха с PostgreSQLdev1ant
 
История успеха Яндекс.Почты с PostgreSQL / Владимир Бородин (Яндекс)
История успеха Яндекс.Почты с PostgreSQL / Владимир Бородин (Яндекс)История успеха Яндекс.Почты с PostgreSQL / Владимир Бородин (Яндекс)
История успеха Яндекс.Почты с PostgreSQL / Владимир Бородин (Яндекс)Ontico
 
Долгожданный релиз pg_pathman 1.0 / Александр Коротков, Дмитрий Иванов (Post...
Долгожданный релиз pg_pathman 1.0 / Александр Коротков,  Дмитрий Иванов (Post...Долгожданный релиз pg_pathman 1.0 / Александр Коротков,  Дмитрий Иванов (Post...
Долгожданный релиз pg_pathman 1.0 / Александр Коротков, Дмитрий Иванов (Post...Ontico
 
Внутреннее устройство PostgreSQL: временные таблицы и фрагментация памяти / Г...
Внутреннее устройство PostgreSQL: временные таблицы и фрагментация памяти / Г...Внутреннее устройство PostgreSQL: временные таблицы и фрагментация памяти / Г...
Внутреннее устройство PostgreSQL: временные таблицы и фрагментация памяти / Г...Ontico
 
Новые возможности полнотекстового поиска в PostgreSQL / Олег Бартунов (Postgr...
Новые возможности полнотекстового поиска в PostgreSQL / Олег Бартунов (Postgr...Новые возможности полнотекстового поиска в PostgreSQL / Олег Бартунов (Postgr...
Новые возможности полнотекстового поиска в PostgreSQL / Олег Бартунов (Postgr...Ontico
 
PostgreSQL: практические примеры оптимизации SQL-запросов / Иван Фролков (Po...
PostgreSQL: практические примеры оптимизации SQL-запросов /  Иван Фролков (Po...PostgreSQL: практические примеры оптимизации SQL-запросов /  Иван Фролков (Po...
PostgreSQL: практические примеры оптимизации SQL-запросов / Иван Фролков (Po...Ontico
 

Viewers also liked (6)

История небольшого успеха с PostgreSQL
История небольшого успеха с PostgreSQLИстория небольшого успеха с PostgreSQL
История небольшого успеха с PostgreSQL
 
История успеха Яндекс.Почты с PostgreSQL / Владимир Бородин (Яндекс)
История успеха Яндекс.Почты с PostgreSQL / Владимир Бородин (Яндекс)История успеха Яндекс.Почты с PostgreSQL / Владимир Бородин (Яндекс)
История успеха Яндекс.Почты с PostgreSQL / Владимир Бородин (Яндекс)
 
Долгожданный релиз pg_pathman 1.0 / Александр Коротков, Дмитрий Иванов (Post...
Долгожданный релиз pg_pathman 1.0 / Александр Коротков,  Дмитрий Иванов (Post...Долгожданный релиз pg_pathman 1.0 / Александр Коротков,  Дмитрий Иванов (Post...
Долгожданный релиз pg_pathman 1.0 / Александр Коротков, Дмитрий Иванов (Post...
 
Внутреннее устройство PostgreSQL: временные таблицы и фрагментация памяти / Г...
Внутреннее устройство PostgreSQL: временные таблицы и фрагментация памяти / Г...Внутреннее устройство PostgreSQL: временные таблицы и фрагментация памяти / Г...
Внутреннее устройство PostgreSQL: временные таблицы и фрагментация памяти / Г...
 
Новые возможности полнотекстового поиска в PostgreSQL / Олег Бартунов (Postgr...
Новые возможности полнотекстового поиска в PostgreSQL / Олег Бартунов (Postgr...Новые возможности полнотекстового поиска в PostgreSQL / Олег Бартунов (Postgr...
Новые возможности полнотекстового поиска в PostgreSQL / Олег Бартунов (Postgr...
 
PostgreSQL: практические примеры оптимизации SQL-запросов / Иван Фролков (Po...
PostgreSQL: практические примеры оптимизации SQL-запросов /  Иван Фролков (Po...PostgreSQL: практические примеры оптимизации SQL-запросов /  Иван Фролков (Po...
PostgreSQL: практические примеры оптимизации SQL-запросов / Иван Фролков (Po...
 

Similar to 2015.07.16 Способы диагностики PostgreSQL

Percona Live UK 2014 Part III
Percona Live UK 2014  Part IIIPercona Live UK 2014  Part III
Percona Live UK 2014 Part IIIAlkin Tezuysal
 
Kernel Recipes 2017 - Performance analysis Superpowers with Linux BPF - Brend...
Kernel Recipes 2017 - Performance analysis Superpowers with Linux BPF - Brend...Kernel Recipes 2017 - Performance analysis Superpowers with Linux BPF - Brend...
Kernel Recipes 2017 - Performance analysis Superpowers with Linux BPF - Brend...Anne Nicolas
 
Kernel Recipes 2017: Performance Analysis with BPF
Kernel Recipes 2017: Performance Analysis with BPFKernel Recipes 2017: Performance Analysis with BPF
Kernel Recipes 2017: Performance Analysis with BPFBrendan Gregg
 
OSSNA 2017 Performance Analysis Superpowers with Linux BPF
OSSNA 2017 Performance Analysis Superpowers with Linux BPFOSSNA 2017 Performance Analysis Superpowers with Linux BPF
OSSNA 2017 Performance Analysis Superpowers with Linux BPFBrendan Gregg
 
Oracle to Postgres Migration - part 2
Oracle to Postgres Migration - part 2Oracle to Postgres Migration - part 2
Oracle to Postgres Migration - part 2PgTraining
 
New features in Performance Schema 5.7 in action
New features in Performance Schema 5.7 in actionNew features in Performance Schema 5.7 in action
New features in Performance Schema 5.7 in actionSveta Smirnova
 
監査ログをもっと身近に!〜統合監査のすすめ〜
監査ログをもっと身近に!〜統合監査のすすめ〜監査ログをもっと身近に!〜統合監査のすすめ〜
監査ログをもっと身近に!〜統合監査のすすめ〜Michitoshi Yoshida
 
Fosdem managing my sql with percona toolkit
Fosdem managing my sql with percona toolkitFosdem managing my sql with percona toolkit
Fosdem managing my sql with percona toolkitFrederic Descamps
 
Linux kernel tracing superpowers in the cloud
Linux kernel tracing superpowers in the cloudLinux kernel tracing superpowers in the cloud
Linux kernel tracing superpowers in the cloudAndrea Righi
 
Oracle Basics and Architecture
Oracle Basics and ArchitectureOracle Basics and Architecture
Oracle Basics and ArchitectureSidney Chen
 
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
 
PGDay.Amsterdam 2018 - Stefan Fercot - Save your data with pgBackRest
PGDay.Amsterdam 2018 - Stefan Fercot - Save your data with pgBackRestPGDay.Amsterdam 2018 - Stefan Fercot - Save your data with pgBackRest
PGDay.Amsterdam 2018 - Stefan Fercot - Save your data with pgBackRestPGDay.Amsterdam
 
2022 COSCUP - Let's speed up your PostgreSQL services!.pptx
2022 COSCUP - Let's speed up your PostgreSQL services!.pptx2022 COSCUP - Let's speed up your PostgreSQL services!.pptx
2022 COSCUP - Let's speed up your PostgreSQL services!.pptxJosé Lin
 
Reverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande ModemReverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande ModemCyber Security Alliance
 
CQURE_BHAsia19_Paula_Januszkiewicz_slides
CQURE_BHAsia19_Paula_Januszkiewicz_slidesCQURE_BHAsia19_Paula_Januszkiewicz_slides
CQURE_BHAsia19_Paula_Januszkiewicz_slidesZuzannaKornecka
 
Container: is it safe enough to run you application?
Container: is it safe enough to run you application?Container: is it safe enough to run you application?
Container: is it safe enough to run you application?Aleksey Zalesov
 
USENIX ATC 2017 Performance Superpowers with Enhanced BPF
USENIX ATC 2017 Performance Superpowers with Enhanced BPFUSENIX ATC 2017 Performance Superpowers with Enhanced BPF
USENIX ATC 2017 Performance Superpowers with Enhanced BPFBrendan Gregg
 
Tracer Evaluation
Tracer EvaluationTracer Evaluation
Tracer EvaluationQiao Han
 
StormCrawler at Bristech
StormCrawler at BristechStormCrawler at Bristech
StormCrawler at BristechJulien Nioche
 

Similar to 2015.07.16 Способы диагностики PostgreSQL (20)

Percona Live UK 2014 Part III
Percona Live UK 2014  Part IIIPercona Live UK 2014  Part III
Percona Live UK 2014 Part III
 
Kernel Recipes 2017 - Performance analysis Superpowers with Linux BPF - Brend...
Kernel Recipes 2017 - Performance analysis Superpowers with Linux BPF - Brend...Kernel Recipes 2017 - Performance analysis Superpowers with Linux BPF - Brend...
Kernel Recipes 2017 - Performance analysis Superpowers with Linux BPF - Brend...
 
Kernel Recipes 2017: Performance Analysis with BPF
Kernel Recipes 2017: Performance Analysis with BPFKernel Recipes 2017: Performance Analysis with BPF
Kernel Recipes 2017: Performance Analysis with BPF
 
OSSNA 2017 Performance Analysis Superpowers with Linux BPF
OSSNA 2017 Performance Analysis Superpowers with Linux BPFOSSNA 2017 Performance Analysis Superpowers with Linux BPF
OSSNA 2017 Performance Analysis Superpowers with Linux BPF
 
Oracle to Postgres Migration - part 2
Oracle to Postgres Migration - part 2Oracle to Postgres Migration - part 2
Oracle to Postgres Migration - part 2
 
New features in Performance Schema 5.7 in action
New features in Performance Schema 5.7 in actionNew features in Performance Schema 5.7 in action
New features in Performance Schema 5.7 in action
 
監査ログをもっと身近に!〜統合監査のすすめ〜
監査ログをもっと身近に!〜統合監査のすすめ〜監査ログをもっと身近に!〜統合監査のすすめ〜
監査ログをもっと身近に!〜統合監査のすすめ〜
 
Fosdem managing my sql with percona toolkit
Fosdem managing my sql with percona toolkitFosdem managing my sql with percona toolkit
Fosdem managing my sql with percona toolkit
 
Linux kernel tracing superpowers in the cloud
Linux kernel tracing superpowers in the cloudLinux kernel tracing superpowers in the cloud
Linux kernel tracing superpowers in the cloud
 
Oracle Basics and Architecture
Oracle Basics and ArchitectureOracle Basics and Architecture
Oracle Basics and Architecture
 
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
 
PGDay.Amsterdam 2018 - Stefan Fercot - Save your data with pgBackRest
PGDay.Amsterdam 2018 - Stefan Fercot - Save your data with pgBackRestPGDay.Amsterdam 2018 - Stefan Fercot - Save your data with pgBackRest
PGDay.Amsterdam 2018 - Stefan Fercot - Save your data with pgBackRest
 
2022 COSCUP - Let's speed up your PostgreSQL services!.pptx
2022 COSCUP - Let's speed up your PostgreSQL services!.pptx2022 COSCUP - Let's speed up your PostgreSQL services!.pptx
2022 COSCUP - Let's speed up your PostgreSQL services!.pptx
 
Reverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande ModemReverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande Modem
 
CQURE_BHAsia19_Paula_Januszkiewicz_slides
CQURE_BHAsia19_Paula_Januszkiewicz_slidesCQURE_BHAsia19_Paula_Januszkiewicz_slides
CQURE_BHAsia19_Paula_Januszkiewicz_slides
 
Container: is it safe enough to run you application?
Container: is it safe enough to run you application?Container: is it safe enough to run you application?
Container: is it safe enough to run you application?
 
USENIX ATC 2017 Performance Superpowers with Enhanced BPF
USENIX ATC 2017 Performance Superpowers with Enhanced BPFUSENIX ATC 2017 Performance Superpowers with Enhanced BPF
USENIX ATC 2017 Performance Superpowers with Enhanced BPF
 
Tracer Evaluation
Tracer EvaluationTracer Evaluation
Tracer Evaluation
 
StormCrawler at Bristech
StormCrawler at BristechStormCrawler at Bristech
StormCrawler at Bristech
 

Recently uploaded

Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
Comparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization TechniquesComparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization Techniquesugginaramesh
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction managementMariconPadriquez1
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 

Recently uploaded (20)

Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Comparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization TechniquesComparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization Techniques
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction management
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 

2015.07.16 Способы диагностики PostgreSQL

  • 4. Р. Чернышевский и А. Герцен Кто виноват? Что делать?
  • 5. Во что упёрлись? Системные ресурсы: 〉 Процессор/память/диски/сеть Внутренние процессы базы: 〉 Heavy-weight locks 〉 Всё остальное 5
  • 13. 13
  • 16. 16
  • 17. 17 SELECT datname, queryid, round(total_time::numeric, 2) AS total_time, calls, pg_size_pretty((shared_blks_hit+shared_blks_read)*8192 - reads) AS memory_hit, pg_size_pretty(reads) AS disk_read, pg_size_pretty(writes) AS disk_write, round(user_time::numeric, 2) AS user_time, round(system_time::numeric, 2) AS system_time FROM pg_stat_statements s JOIN pg_stat_kcache() k USING (userid, dbid, queryid) JOIN pg_database d ON s.dbid = d.oid WHERE datname != 'postgres' AND datname NOT LIKE 'template%' ORDER BY total_time DESC LIMIT 10;
  • 18. 18 SELECT datname, queryid, round(total_time::numeric, 2) AS total_time, calls, pg_size_pretty((shared_blks_hit+shared_blks_read)*8192 - reads) AS memory_hit, pg_size_pretty(reads) AS disk_read, pg_size_pretty(writes) AS disk_write, round(user_time::numeric, 2) AS user_time, round(system_time::numeric, 2) AS system_time FROM pg_stat_statements s JOIN pg_stat_kcache() k USING (userid, dbid, queryid) JOIN pg_database d ON s.dbid = d.oid WHERE datname != 'postgres' AND datname NOT LIKE 'template%' ORDER BY total_time DESC LIMIT 10;
  • 19. 19
  • 20.
  • 21. Проблемы сложнее Сильное увеличение нагрузки на I/O приводит к потреблению всего процессорного времени в system 21
  • 24. Кобб We need to go deeper
  • 25. SystemTap 〉 Можно посмотреть очень многое 〉 Требует пересборки PostgreSQL 〉 Быстро stap не написать, а иметь готовые на все случаи жизни не получится 〉 Не стоит использовать в бою https://simply.name/postgresql-and-systemtap.html 25
  • 26. GDB # yum -y install postgresql94-debuginfo # cat /usr/local/yandex/gdb_bt_cmd bt # fgrep gdb /usr/bin/bt cmd = 'gdb -batch -x /usr/local/yandex/gdb_bt_cmd /usr/pgsql-9.4/bin/postgres %d' % pid # 26
  • 27. GDB #0 0x00007fdacd68bf27 in semop () from /lib64/libc.so.6 #1 0x000000000061fe27 in PGSemaphoreLock (sema=0x7fdbe02f84b0, interruptOK=0 '000') at pg_sema.c:421 #2 0x00000000006769ba in LWLockAcquireCommon (l=0x7fdacf400560, mode=LW_SHARED) at lwlock.c:626 #3 LWLockAcquire (l=0x7fdacf400560, mode=LW_SHARED) at lwlock.c:467 #4 0x000000000065db61 in BufferAlloc (smgr=0x1b30770, relpersistence=112 'p', forkNum=MAIN_FORKNUM, blockNum=21261, mode=RBM_NORMAL, strategy=0x0, hit=0x7fff20e86eff "") at bufmgr.c:591 #5 ReadBuffer_common (smgr=0x1b30770, relpersistence=112 'p', forkNum=MAIN_FORKNUM, blockNum=21261, mode=RBM_NORMAL, strategy=0x0, hit=0x7fff20e86eff "") at bufmgr.c:340 #6 0x000000000065e55e in ReadBufferExtended (reln=0x7fdacf08ede0, forkNum=MAIN_FORKNUM, blockNum=21261, mode=<value optimized out>, strategy=<value 27
  • 28. GDB 〉 https://github.com/dev1ant/misc/blob/master/bt 〉 Не складывает production 〉 Пакеты *-debuginfo есть во всех репозиториях страны 〉 С точностью до строчки кода понятно, что происходит 28
  • 32. Пример 1 ALTER INDEX mail.i_box_uid_lids SET (FASTUPDATE=OFF); postgresql.org/docs/current/static/gin-implementation.html 32
  • 35. Пример 2 0x00007fb53eebfe97 in semop () from /lib64/libc.so.6 #0 0x00007fb53eebfe97 in semop () from /lib64/libc.so.6 #1 0x000000000061fe27 in PGSemaphoreLock (sema=0x7fb757757430, interruptOK=0 '000') at pg_sema.c:421 #2 0x00000000006769ba in LWLockAcquireCommon (l=0x7fb540c000a0, mode=LW_EXCLUSIVE) at lwlock.c:626 #3 LWLockAcquire (l=0x7fb540c000a0, mode=LW_EXCLUSIVE) at lwlock.c:467 #4 0x000000000065ebde in StrategyGetBuffer (strategy=0x0, lock_held=0x7fffb44cdebe "001001030001") at freelist.c:134 #5 0x000000000065de25 in BufferAlloc (smgr=0x2a34090, relpersistence=112 'p', forkNum=MAIN_FORKNUM, blockNum=1072861, mode=RBM_NORMAL, strategy=0x0, hit=0x7fffb44cdf2f "") at bufmgr.c:648 35
  • 36. Пример 2 # echo never > /sys/kernel/mm/redhat_transparent_hugepage/enabled postgresql.org/message-id/55356496.9060607@aule.net 36
  • 39. Пример 3 # grep '^#4 ' /tmp/bt | awk '{print $2, $4, $NF}' | sort | uniq -c | sort -rn 126 0x000000000065db61 BufferAlloc bufmgr.c:591 67 0x000000000065e03a BufferAlloc bufmgr.c:760 43 0x00000000005c8c3b pq_getbyte pqcomm.c:899 39 0x000000000065dd93 BufferAlloc bufmgr.c:765 6 0x00000000004b52bb RecordTransactionCommit xact.c:1194 4 0x000000000065da0e ReadBuffer_common bufmgr.c:476 1 ReadBuffer_common relpersistence=112 bufmgr.c:340 1 exec_eval_expr expr=0x166e908, pl_exec.c:4796 39
  • 40. Пример 3 〉 Уменьшение shared_buffers 〉 src/include/storage/lwlock.h -#define NUM_BUFFER_PARTITIONS 16 +#define NUM_BUFFER_PARTITIONS 128 〉 git.postgresql.org/pg/commitdiff/d72731a7 〉 git.postgresql.org/pg/commitdiff/1dcfb8da 〉 wiki.postgresql.org/wiki/Shared_Buffer_Improvements 40
  • 43. Пример 4 0x00007f54a71444c0 in __read_nocancel () from /lib64/libc.so.6 #0 0x00007f54a71444c0 in __read_nocancel () from /lib64/libc.so.6 #1 0x000000000065d2f5 in FileRead (file=<value optimized out>, buffer=0x7f53ac0dba20 ";9", amount=8192) at fd.c:1286 #2 0x000000000067acad in mdread (reln=<value optimized out>, forknum=<value optimized out>, blocknum=12063036, buffer=0x7f53ac0dba20 ";9") at md.c:679 #3 0x0000000000659b4e in ReadBuffer_common (smgr=<value optimized out>, relpersistence=112 'p', forkNum=MAIN_FORKNUM, blockNum=12063036, mode=RBM_NORMAL_NO_LOG, strategy=0x0, hit=0x7fff898a912f "") at bu fmgr.c:476 #4 0x000000000065a61b in ReadBufferWithoutRelcache (rnode=..., forkNum=MAIN_FORKNUM, blockNum=12063036, mode=<value optimized out>, strategy=<value optimized out>) at bufmgr.c:287 #5 0x00000000004cfb78 in XLogReadBufferExtended (rnode=..., forknum=MAIN_FORKNUM, blkno=12063036, mode=RBM_NORMAL_NO_LOG) at xlogutils.c:324 #6 0x00000000004a3651 in btree_xlog_vacuum (lsn=71744181579864, record=0x1e49dc0) at nbtxlog.c:522 #7 btree_redo (lsn=71744181579864, record=0x1e49dc0) at nbtxlog.c:1144 #8 0x00000000004c903a in StartupXLOG () at xlog.c:6827 #9 0x000000000062f8bf in StartupProcessMain () at startup.c:224 #10 0x00000000004d3e9a in AuxiliaryProcessMain (argc=2, argv=0x7fff898a98a0) at bootstrap.c:416 #11 0x000000000062a99c in StartChildProcess (type=StartupProcess) at postmaster.c:5146 43
  • 44. Пример 4 〉 https://clck.ru/9Xfx6 〉 https://commitfest.postgresql.org/5/233/ 〉 Секционирование больших insert-only таблиц 44
  • 46. Какие ожидания нужно мониторить? 〉 Locks (heavyweight) 〉 LWLocks (lightweight locks) 〉 Latch 〉 Network 〉 Storage (IO) 46
  • 47. Какие недостатки у текущих инструментов? 〉 Часто нельзя использовать в production 〉 Они разрозненные и их много 〉 Тяжело настраиваются и устанавливаются 47
  • 48. pg_stat_wait 〉 Profiling 〉 Трассировка в файл 〉 История ожиданий 48
  • 49. Требования 〉 Минимальный overhead 〉 Возможность просмотра в онлайн-режиме 〉 Высокая точность 〉 Один инструмент для всех типов ожиданий 49
  • 50. pg_stat_wait_profile 50 b1=# SELECT * FROM pg_stat_wait_profile ORDER BY wait_count DESC; pid | class_id | class_name | event_id | event_name | wait_time | wait_count -------+----------+------------+----------+---------------------+-------------+------------ 10781 | 4 | Latch | 0 | Latch | 90939504509 | 18217 11085 | 4 | Latch | 0 | Latch | 51834 | 9209 11085 | 5 | Network | 1 | WRITE | 65355 | 576 11085 | 3 | Storage | 0 | READ | 2273 | 188 11085 | 5 | Network | 0 | READ | 90932631592 | 93 10779 | 3 | Storage | 1 | WRITE | 1440 | 65 10782 | 3 | Storage | 0 | READ | 1040 | 43 10780 | 3 | Storage | 1 | WRITE | 367 | 15 5829 | 5 | Network | 1 | WRITE | 11 | 3 6025 | 5 | Network | 1 | WRITE | 10 | 2 11085 | 1 | LWLocks | 41 | BufferPartitionLock | 1355 | 2 11085 | 3 | Storage | 1 | WRITE | 9 | 2 5829 | 5 | Network | 0 | READ | 462 | 2
  • 51. pg_stat_wait_history 51 b1=# SELECT * FROM pg_stat_wait_history WHERE class_id != 4 LIMIT 2; pid | sample_ts | class_id | class_name | event_id | event_name | wait_time | p1 | p2 | p3 | p4 | p5 -------+-------------------------------+----------+------------+----------+------------+----------- +------+-------+-------+----+---- 11085 | 2015-07-10 10:37:41.321489-04 | 3 | Storage | 1 | WRITE | 3520 | 1663 | 16384 | 16458 | 0 | 0 11085 | 2015-07-10 10:37:09.390442-04 | 5 | Network | 1 | WRITE | 7815 | 0 | 0 | 0 | 0 | 0 〉class_id - класс ожидания (lock, lwlock, io, latch, or network) 〉event_id - событие 〉p1 .. p5 - параметры ожидания
  • 52. Трассировка Даёт большой overhead, используйте только для отдельных сессий terminal 1: $ psql b1 terminal 2: $ ps ax | grep postgres <…> 11085 ? Ss 0:00 postgres: postgres b1 [local] idle $ psql b1 -c "select pg_start_trace(11085, '/tmp/f.trace')" terminal 1: b1=# CREATE TABLE t1 AS SELECT i, i*10 AS i1 FROM generate_series(1,10) i; SELECT 10 52
  • 53. Трассировка terminal 2: $ tail -f /tmp/f.trace stop 2015-07-10 10:03:35.603458-04 Network start 2015-07-10 10:03:35.603464-04 Network READ 0 0 0 0 0 stop 2015-07-10 10:03:44.099587-04 Network start 2015-07-10 10:03:44.100401-04 Storage READ 1663 16384 1259 2 0 stop 2015-07-10 10:03:44.100424-04 Storage start 2015-07-10 10:03:44.102549-04 Network WRITE 0 0 0 0 0 stop 2015-07-10 10:03:44.102573-04 Network start 2015-07-10 10:03:44.102582-04 Network READ 0 0 0 0 0 stop 2015-07-10 10:05:33.029975-04 Network start 2015-07-10 10:05:33.030205-04 Storage READ 1663 16384 2691 0 28 stop 2015-07-10 10:05:33.030233-04 Storage start 2015-07-10 10:05:33.030246-04 Storage READ 1663 16384 1255 0 50 stop 2015-07-10 10:05:33.03026-04 Storage 53
  • 54. 54 Backend Backend Backend Collector Shared memory ProcArray History Current view History view Profile view Как устроен pg_stat_wait Profile per wait Profile per wait Profile per wait
  • 55. Сбор истории 55 Backend Backend Backend ProcArray Collector
  • 56. Overhead Тестовая конфигурация: 〉Intel(R) Xeon(R) CPU X5675@3.07GHz, 24 cores 〉RAM 24 GB 〉pgbench -S 500 ~ 1.6 Gb Избегаем влияния дисковой подсистемы: 〉fsync off 〉tmpfs 56
  • 57. Monitoring off [ildus@1-i-kurbangaliev postgrespro]$ pgbench -S b1 -c 96 -j 4 -T 300 starting vacuum...end. transaction type: SELECT only scaling factor: 500 query mode: simple number of clients: 96 number of threads: 4 duration: 300 s number of transactions actually processed: 39349816 latency average: 0.732 ms tps = 131130.859559 (including connections establishing) tps = 131153.752204 (excluding connections establishing) 57
  • 58. Monitoring on [ildus@1-i-kurbangaliev postgrespro]$ pgbench -S b1 -c 96 -j 4 -T 300 starting vacuum...end. transaction type: SELECT only scaling factor: 500 query mode: simple number of clients: 96 number of threads: 4 duration: 300 s number of transactions actually processed: 39172607 latency average: 0.735 ms tps = 130574.626755 (including connections establishing) tps = 130600.767440 (excluding connections establishing) 58
  • 59. Open source 〉 https://github.com/postgrespro/postgres 〉 https://clck.ru/9XsnG 〉 https://clck.ru/9XsnE 59
  • 61. Было 0x00007f10e01d4f27 in semop () from /lib64/libc.so.6 #0 0x00007f10e01d4f27 in semop () from /lib64/libc.so.6 #1 0x000000000061fe27 in PGSemaphoreLock (sema=0x7f11f2d4f430, interruptOK=0 '000') at pg_sema.c:421 #2 0x00000000006769ba in LWLockAcquireCommon (l=0x7f10e1e00120, mode=LW_EXCLUSIVE) at lwlock.c:626 #3 LWLockAcquire (l=0x7f10e1e00120, mode=LW_EXCLUSIVE) at lwlock.c:467 #4 0x0000000000667862 in ProcArrayEndTransaction (proc=0x7f11f2d4f420, latestXid=182562881) at procarray.c:404 #5 0x00000000004b579b in CommitTransaction () at xact.c:1957 #6 0x00000000004b6ae5 in CommitTransactionCommand () at xact.c:2727 #7 0x00000000006819d9 in finish_xact_command () at postgres.c:2437 #8 0x0000000000684f05 in PostgresMain (argc=<value optimized out>, argv=<value optimized out>, dbname=0x21e1a70 "xivadb", username=<value optimized out>) at postgres.c:4270 #9 0x0000000000632d7d in BackendRun (argc=<value optimized out>, argv=<value optimized out>) at postmaster.c:4155 #10 BackendStartup (argc=<value optimized out>, argv=<value optimized out>) at postmaster.c: 3829 61
  • 63. 63
  • 64. 64
  • 65. 65
  • 66. 66
  • 68. Владимир Бородин Системный администратор Контакты d0uble@yandex-team.ru Ильдус Курбангалиев Разработчик @man_brain i.kurbangaliev@postgrespro.ru