PostgreSQL 9.3.25 Documentation | ||||
---|---|---|---|---|
Prev | Up | Chapter 29. Reliability and the Write-Ahead Log | Next |
Write-Ahead Logging (WAL) is a standard method for ensuring data integrity. A detailed description can be found in most (if not all) books about transaction processing. Briefly, WAL's central concept is that changes to data files (where tables and indexes reside) must be written only after those changes have been logged, that is, after log records describing the changes have been flushed to permanent storage. If we follow this procedure, we do not need to flush data pages to disk on every transaction commit, because we know that in the event of a crash we will be able to recover the database using the log: any changes that have not been applied to the data pages can be redone from the log records. (This is roll-forward recovery, also known as REDO.)
Tip: Because WAL restores database file contents after a crash, journaled file systems are not necessary for reliable storage of the data files or WAL files. In fact, journaling overhead can reduce performance, especially if journaling causes file system data to be flushed to disk. Fortunately, data flushing during journaling can often be disabled with a file system mount option, e.g. data=writeback on a Linux ext3 file system. Journaled file systems do improve boot speed after a crash.
Using WAL results in a
significantly reduced number of disk writes, because only the log
file needs to be flushed to disk to guarantee that a transaction is
committed, rather than every data file changed by the transaction.
The log file is written sequentially, and so the cost of syncing
the log is much less than the cost of flushing the data pages. This
is especially true for servers handling many small transactions
touching different parts of the data store. Furthermore, when the
server is processing many small concurrent transactions, one
fsync
of the log file may suffice to
commit many transactions.
WAL also makes it possible to support on-line backup and point-in-time recovery, as described in Section 24.3. By archiving the WAL data we can support reverting to any time instant covered by the available WAL data: we simply install a prior physical backup of the database, and replay the WAL log just as far as the desired time. What's more, the physical backup doesn't have to be an instantaneous snapshot of the database state — if it is made over some period of time, then replaying the WAL log for that period will fix any internal inconsistencies.
嗓子干痒吃什么药 | 手腕长痣代表什么意思 | 直接胆红素高是什么病 | 男生为什么会勃起 | 1970年属狗是什么命 |
扫兴什么意思 | 什么是肝炎 | 燕麦色是什么颜色 | 血压不稳定是什么原因 | 子宫肌瘤不能吃什么 |
胃溃疡不能吃什么食物 | 香草味是什么味道 | 发物是什么意思 | 人为什么会中暑 | 消症是什么意思 |
一阴一阳是什么数字 | 井泉水命什么意思 | 有缘无分什么意思 | 早上吃什么早餐最好 | 人为什么会说梦话 |
早泄是什么hcv9jop7ns0r.cn | 羊绒和羊毛有什么区别hcv8jop2ns0r.cn | 西班牙用的是什么货币hcv8jop5ns2r.cn | 四大发明是什么hcv9jop7ns1r.cn | 解痉是什么意思hcv9jop2ns7r.cn |
宜余事勿取是什么意思youbangsi.com | 阳气不足吃什么药hcv8jop6ns7r.cn | rover是什么意思hcv8jop2ns0r.cn | 宁字属于五行属什么hcv7jop9ns1r.cn | 40年属什么hcv8jop7ns2r.cn |
电音是什么意思hcv9jop6ns8r.cn | 吃月饼是什么生肖aiwuzhiyu.com | 蟒袍是什么人穿的hcv8jop3ns3r.cn | 屠苏是什么意思hcv9jop7ns3r.cn | 波澜壮阔是什么意思hcv8jop2ns7r.cn |
保妇康栓是治疗什么的hcv7jop9ns1r.cn | 夜未央是什么意思hcv8jop5ns3r.cn | 外卖吃什么hcv8jop7ns3r.cn | aojo眼镜什么档次hcv9jop8ns2r.cn | 什么样的人容易得心梗hcv8jop2ns3r.cn |