博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
fsync体会
阅读量:7054 次
发布时间:2019-06-28

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

看这个链接:

是这样说的:

fsync (boolean)If this parameter is on, the PostgreSQL server will try to make sure that updates are physically written to disk, by issuing fsync() system calls or various equivalent methods (see wal_sync_method). This ensures that the database cluster can recover to a consistent state after an operating system or hardware crash.While turning off fsync is often a performance benefit, this can result in unrecoverable data corruption in the event of a power failure or system crash. Thus it is only advisable to turn off fsync if you can easily recreate your entire database from external data.Examples of safe circumstances for turning off fsync include the initial loading of a new database cluster from a backup file, using a database cluster for processing a batch of data after which the database will be thrown away and recreated, or for a read-only database clone which gets recreated frequently and is not used for failover. High quality hardware alone is not a sufficient justification for turning off fsync.In many situations, turning off synchronous_commit for noncritical transactions can provide much of the potential performance benefit of turning off fsync, without the attendant risks of data corruption.fsync can only be set in the postgresql.conf file or on the server command line. If you turn this parameter off, also consider turning off full_page_writes.

我的实验:

把 postgresql.conf 中的 fsync 设置为off之后,再来看sql执行动作:

pgsql=# select * from test; textcol | intcol ---------+-------- a       |      1 a       |      2 b       |      5 b       |      6(4 rows)pgsql=#
pgsql=# show fsync; fsync ------- off(1 row)pgsql=#

执行操作:

begin;insert into test values('aaaaa',12345);commit;

然后直接关机,使得OS级别的缓存没有机会写入磁盘。

再次开机看数据,发现上述数据没有保存:

pgsql=# select * from test; textcol | intcol ---------+-------- a       |      1 a       |      2 b       |      5 b       |      6(4 rows)pgsql=#

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

你可能感兴趣的文章
linux下的java开发环境
查看>>
Bootstrap使用记录
查看>>
从一场场大型网站灾难过后的BUG:根
查看>>
Linux系统下怎样利用nc命令来监控检测服务器的端口使用情况
查看>>
git命令总结
查看>>
tomcat高访问jvm配置
查看>>
谢烟客---------二进制安装MariaDB,管理关系型数据库的基本组件
查看>>
JS 判断手机浏览器
查看>>
Xcode WorkSpace静态库多项目依赖
查看>>
【C语言】 实现memset
查看>>
JS 流程设计器
查看>>
blog小记
查看>>
我的友情链接
查看>>
fileoper.py
查看>>
我的友情链接
查看>>
shell脚本将指定目录下前3天日期目录使用tar打包后并将其删除源日期目录
查看>>
类的静态成员
查看>>
osi七层模型的分类
查看>>
潍坊SEO教程之网站关键词密度
查看>>
HTTPS原理和CA证书申请(满满的干货)
查看>>