为什么PostgreSQL checkpointer后台进程使用这么多内存
这篇文章主要讲解了“为什么PostgreSQL checkpointer后台进程使用这么多内存”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“为什么PostgreSQL checkpointer后台进程使用这么多内存”吧!
本节内容来源于PGer的一个问题:
Q:
为什么checkpointer后台进程使用这么多内存?
[pg12@localhost~]$ps-aux|greppostgrespg1215060.01.875315634704?Ss10:300:00/appdb/xdb/pg12beta1/bin/postgrespg1215070.00.01873041472?Ss10:300:00postgres:loggerpg1215090.024.1754120452672?Ss10:300:04postgres:checkpointerpg1215100.028.4753292533184?Ss10:300:08postgres:backgroundwriterpg1215110.00.975326018012?Ss10:300:11postgres:walwriterpg1215130.00.01894201448?Ss10:300:00postgres:archiverlastwas00000001000000020000005Cpg1215140.00.01895561324?Ss10:300:00postgres:statscollectorpg1215150.00.17536881984?Ss10:300:00postgres:logicalreplicationlauncherpg1222810.00.0112660972pts/3S+16:380:00grep--color=autopostgres[pg12@localhost~]$grep'shared'$PGDATA/postgresql.confshared_buffers=512MB#min128kB#shared_memory_type=mmap#thedefaultisthefirstoptiondynamic_shared_memory_type=posix#thedefaultisthefirstoption#wal_buffers=-1#min32kB,-1setsbasedonshared_buffers#shared_preload_libraries=''#(changerequiresrestart)
比如上例,共享内存设置为512MB,在2G内存的机器上,checkpointer和background writer进程占用了差不多25%的内存大小.
A:
resident” RAM of a postgres subprocess is often just be the fraction of shared_buffers it’s read/written. checkpointer must necessarily read all dirty pages from s-b and write out to disk (by way of page cache), so that’s why its RSS is nearly 32GB. And the recovery process is continuously writing into s-b.
原因是checkpointer和bg writer需要从shared memory中读取数据(从s-b到page cache)并刷到磁盘上,因此给人占用大量内存的假象.
感谢各位的阅读,以上就是“为什么PostgreSQL checkpointer后台进程使用这么多内存”的内容了,经过本文的学习后,相信大家对为什么PostgreSQL checkpointer后台进程使用这么多内存这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是亿速云,小编将为大家推送更多相关知识点的文章,欢迎关注!
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。