os:centos 7.4
postgresql:10.4
第一个窗口
创建表,向表中插入大量数据
$ psql
psql (10.4)
Type "help" for help.
postgres=# create table test01(id integer, val char(1000));
CREATE TABLE
postgres=# insert into test01 values(generate_series(1,5000000),repeat( chr(int4(random()*26)+65),1000));
第二个窗口,观察os层面postgres用户的进程内存占用
# watch "ps -aux |head -1;ps -aux|grep -i postgres;free -m"
Every 2.0s: ps -aux |grep -i postgres Mon Aug 20 23:20:43 2018
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1570 0.0 0.0 220660 96 pts/0 S 22:53 0:00 su - postgres
postgres 1571 0.0 0.0 116720 68 pts/0 S 22:53 0:00 -bash
postgres 1629 0.0 1.3 729832 27040 pts/0 S 22:53 0:00 /usr/pgsql-10/bin/postgres -D /var/lib/pgsql/10/data
postgres 1630 0.0 0.0 170624 212 ? Ss 22:53 0:00 postgres: peiyb: logger process
postgres 1632 0.0 18.2 730124 372980 ? Ss 22:53 0:00 postgres: peiyb: checkpointer process
postgres 1633 0.0 0.1 729968 2604 ? Ss 22:53 0:00 postgres: peiyb: writer process
postgres 1634 0.0 0.8 729832 16592 ? Ds 22:53 0:00 postgres: peiyb: wal writer process
postgres 1635 0.0 0.0 730396 540 ? Ss 22:53 0:00 postgres: peiyb: autovacuum launcher process
postgres 1636 0.0 0.0 172884 272 ? Ss 22:53 0:00 postgres: peiyb: stats collector process
postgres 1637 0.0 0.0 730252 240 ? Ss 22:53 0:00 postgres: peiyb: bgworker: logical replication launcher
postgres 1649 0.0 0.0 156728 136 pts/0 S+ 22:54 0:00 ./bin/psql
postgres 1650 0.4 90.5 2051040 1854772 ? Ss 22:54 0:07 postgres: peiyb: postgres postgres [local] INSERT
root 2178 0.0 0.0 126428 480 pts/1 S+ 23:04 0:00