> For the complete documentation index, see [llms.txt](https://docs.postgresql.tw/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.postgresql.tw/19/the-sql-language/performance-tips/non-durability.md). Agents can also search and read this documentation through its [MCP server](https://docs.postgresql.tw/~gitbook/mcp).

# 14.5. 非持久性設定 \#

### 14.5. 非持久性設定 [#](#non-durability) <a href="#non-durability" id="non-durability"></a>

持久性（durability）是一項資料庫功能，它保證即使伺服器當機或斷電，已提交的交易仍會被記錄下來。不過，持久性會為資料庫帶來相當大的額外負擔，因此如果你的網站不需要這樣的保證，可以將 PostgreSQL 設定為執行得更快。以下是在這類情況下，可以用來提升效能的組態變更。除了下面特別註明的情況之外，在資料庫軟體當機時仍然能保證持久性；使用這些設定時，只有作業系統突然當機才會造成資料遺失或損毀的風險。

* 將資料庫叢集的資料目錄放在以記憶體為基礎的檔案系統（也就是 RAM 磁碟）中。這可以免除所有資料庫的磁碟 I/O，但資料儲存量會被限制在可用記憶體（或許再加上置換空間）的大小之內。
* 關閉 [fsync](https://docs.postgresql.tw/19/server-administration/runtime-config/runtime-config-wal.md#GUC-FSYNC)；不需要將資料排清（flush）到磁碟。
* 關閉 [synchronous\_commit](https://docs.postgresql.tw/19/server-administration/runtime-config/runtime-config-wal/synchronous-commit.md#guc-synchronous-commit)；可能不需要在每次提交時都強制將 WAL 寫入磁碟。這項設定在*資料庫*當機時確實有遺失交易的風險（但不會造成資料損毀）。
* 關閉 [full\_page\_writes](https://docs.postgresql.tw/19/server-administration/runtime-config/runtime-config-wal.md#GUC-FULL-PAGE-WRITES)；不需要防範部分頁面寫入。
* 增加 [max\_wal\_size](https://docs.postgresql.tw/19/server-administration/runtime-config/runtime-config-wal.md#GUC-MAX-WAL-SIZE) 與 [checkpoint\_timeout](https://docs.postgresql.tw/19/server-administration/runtime-config/runtime-config-wal.md#GUC-CHECKPOINT-TIMEOUT)；這會降低檢查點的頻率，但會增加 `/pg_wal` 的儲存空間需求。
* 建立[無日誌資料表](https://docs.postgresql.tw/19/reference/sql-commands/sql-createtable.md#SQL-CREATETABLE-UNLOGGED)（unlogged table）以避免寫入 WAL，但這會使這些資料表在當機時不安全。

***

原文：[PostgreSQL 18.6 Documentation](https://www.postgresql.org/docs/18/non-durability.html)（原文版本：18.6；核對日期：2026-09-11）


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.postgresql.tw/19/the-sql-language/performance-tips/non-durability.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
