суббота, 12 января 2019 г.

Сколько оперативной памяти использует PostgreSQL?

How much RAM is PostgreSQL using?

$ ps -u postgres o pid= | sed 's#[0-9]\+#/proc/&/smaps#'| xargs sudo grep ^Pss: | awk '{A+=$2} END {print A}'

$ pg_top --dbname=demo --host=localhost --username=postgres --password

last pid: 23573;  load avg:  0.06,  0.09,  0.11;       up 0+01:51:28                                                                                                                                 14:41:23
8 processes: 8 sleeping
CPU states:  0.1% user,  0.0% nice,  0.1% system, 99.7% idle,  0.0% iowait
Memory: 4776M used, 11G free, 35M buffers, 2120M cached
DB activity:   0 tps,  0 rollbs/s,   0 buffer r/s, 100 hit%,     38 row r/s,    0 row w/s
DB I/O:     0 reads/s,     0 KB/s,     0 writes/s,     1 KB/s
DB disk: 984.2 GB total, 923.9 GB free (6% used)
Swap:

  PID USERNAME PRI NICE  SIZE   RES STATE   TIME   WCPU    CPU COMMAND
14668 postgres  20    0  356M  185M sleep   0:47  0.01%  0.00% postgres: 10/main: postgres demo 127.0.0.1(34192) idle
 1053 postgres  20    0  313M 8872K sleep   0:01  0.00%  0.00% postgres: 10/main: wal writer process
 1052 postgres  20    0  314M  131M sleep   0:00  0.00%  0.00% postgres: 10/main: writer process
 1051 postgres  20    0  314M  126M sleep   0:00  0.00%  0.00% postgres: 10/main: checkpointer process
 1054 postgres  20    0  314M 6636K sleep   0:00  0.00%  0.00% postgres: 10/main: autovacuum launcher process
15517 postgres  20    0  317M   24M sleep   0:00  0.00%  0.00% postgres: 10/main: postgres demo 127.0.0.1(34268) idle
23574 postgres  20    0  315M   16M sleep   0:00  0.00%  0.00% postgres: 10/main: postgres demo ::1(44446) idle
 1056 postgres  20    0  314M 4968K sleep   0:00  0.00%  0.00% postgres: 10/main: bgworker: logical replication launcher


$ sudo grep -B1 -E '^Size: *[0-9]{6}' /proc/14668/smaps
7feca9c68000-7fecb2dfc000 rw-s 00000000 00:05 18103                      /dev/zero (deleted)
Size:             149072 kB


$ sudo grep -A14 7feca9c68000-7fecb2dfc000 /proc/14668/smaps
7feca9c68000-7fecb2dfc000 rw-s 00000000 00:05 18103                      /dev/zero (deleted)
Size:             149072 kB
KernelPageSize:        4 kB
MMUPageSize:           4 kB
Rss:              135664 kB
Pss:               46961 kB
Shared_Clean:          0 kB
Shared_Dirty:     135660 kB
Private_Clean:         0 kB
Private_Dirty:         4 kB
Referenced:       135664 kB
Anonymous:             0 kB
LazyFree:              0 kB
AnonHugePages:         0 kB
ShmemPmdMapped:        0 kB



$ ps -u postgres o pid= | sed 's#[0-9]\+#/proc/&/smaps#' | xargs sudo grep ^Pss: | awk '{A+=$2} END{print A}'
203953

postgres@u1604:~$ free; /usr/lib/postgresql/10/bin/pg_ctl -D /var/lib/postgresql/10/main -m immediate stop; free
              total        used        free      shared  buff/cache   available
Память:    16425432     2527808    11553792      156700     2343832    13397088
Подкачка:           0           0           0
ожидание завершения работы сервера.... готово
сервер остановлен
              total        used        free      shared  buff/cache   available
Память:    16425432     2512900    11712696        9260     2199836    13559644
Подкачка:           0           0           0
postgres@u1604:~$







Комментариев нет:

Отправить комментарий