博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PostgreSQL Memory for Database Caching(1)
阅读量:2395 次
发布时间:2019-05-10

本文共 1211 字,大约阅读时间需要 4 分钟。

最近一次在给公司的数据库做优化,虽然数据库优化有很多点,这里主要是将对内存使用的优化部分进行总结。

关于PostgreSQL的内存单元设置在postgresql.conf文件里

属性wal_buffers,means how much memory to use for buffering write-ahead log data.

也可以登录数据库后,使用命令行方式:

也可以查询pg_settings表

 首先是设置操作系统的share memory大小

使用LInux shared memory 增加buffer sizes。

设置方式是使用getconf命令,编写脚本,内容如下:
#!/bin/bash
# simple shmsetup script
page_size='getconf PAGE_SIZE'
phys_pages='getconf _PHYS_PAGES'
shmall='expr $phys_pages / 2'
shmmax='expr $shmall \* $page_size'
echo kernel.shmmax = $shmmax
echo kernel.shmall = $shmall
保存的文件名为shmsetup。
使之有效,需要增加到/etc/sysctl.conf文件里,使用命令如下:
./shmsetup >> /etc/sysctl.conf
查看shm状态,使用命令:
sysctl -p
状态结果里有几个说明下:
shmmax is the maximum size(in bytes) for a single shared memory segment.
shmall is the total amount of shared memory(in pages) that all processes on the server can use.
Kernel semaphores
使用命令:ipcs -l,结果如下:

该命令主要是查看相关的限制信息,这里是全部的信息,包括share memory、semaphore、messages三块,在这里主要是查看semaphore的限制值。

也可以使用另一个命令查看如图:
总结如下:
All four of the values here might need to be increased on systems with a large number of processes, setting the same way as the increased shared memory sizes.
Estimating shared memory allocation
PostgreSQL里有一套计算的方式,如图:
这部分主要是将如何去增加share memory,主要在配置文件里去处理。

 

转载地址:http://jpzob.baihongyu.com/

你可能感兴趣的文章
JS--JavaScript访问节点(childNodes、parentNode、firstChild、lastChild、nextSibling、previousSibling)
查看>>
JS--JavaScript节点插入、删除、替换、克隆(appendChild、cloneNode、insertBefore、normalize、removeChild、replaceChild)
查看>>
JS--JavaScript元素节点Element特性、访问元素(getElementById、getElementByTagName)、创建元素createElement
查看>>
Vue.js--$nextTick
查看>>
Vue.js--X-Templates、手动挂载Vue实例
查看>>
Vue.js---自定义指令
查看>>
ES6--Map(Map与Object区别、Map的迭代、Map与Array转换、Map的克隆及合并)
查看>>
ES6--Set(特殊值、类型转换、Set对象的作用)
查看>>
ES6--对象
查看>>
ES6--字符串(拓展的方法、模板字符串)
查看>>
ES6--数组(数组创建、填充、遍历、包含、数组缓冲区、定型数组、扩展运算符)
查看>>
ES--函数(默认参数、箭头函数)
查看>>
ES6--Class类
查看>>
ES6--模块
查看>>
ES6--迭代器(Iterator、迭代过程、可迭代数据类型、可迭代数据结构、定义可迭代对象)
查看>>
ES6--Promise对象
查看>>
ES6--Generator函数
查看>>
ES6--async函数
查看>>
Vue.js--数字输入框组件
查看>>
Vue.js--标签页组件
查看>>