codekingpro/portable-devtools
115k
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>14.5. Non-Durable Settings</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="populate.html" title="14.4. Populating a Database" /><link rel="next" href="parallel-query.html" title="Chapter 15. Parallel Query" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">14.5. Non-Durable Settings</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="populate.html" title="14.4. Populating a Database">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="performance-tips.html" title="Chapter 14. Performance Tips">Up</a></td><th width="60%" align="center">Chapter 14. Performance Tips</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="parallel-query.html" title="Chapter 15. Parallel Query">Next</a></td></tr></table><hr /></div><div class="sect1" id="NON-DURABILITY"><div class="titlepage"><div><div><h2 class="title" style="clear: both">14.5. Non-Durable Settings <a href="#NON-DURABILITY" class="id_link">#</a></h2></div></div></div><a id="id-1.5.13.8.2" class="indexterm"></a><p>3 Durability is a database feature that guarantees the recording of4 committed transactions even if the server crashes or loses5 power. However, durability adds significant database overhead,6 so if your site does not require such a guarantee,7 <span class="productname">PostgreSQL</span> can be configured to run8 much faster. The following are configuration changes you can make9 to improve performance in such cases. Except as noted below, durability10 is still guaranteed in case of a crash of the database software;11 only an abrupt operating system crash creates a risk of data loss12 or corruption when these settings are used.13 14 </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>15 Place the database cluster's data directory in a memory-backed16 file system (i.e., <acronym class="acronym">RAM</acronym> disk). This eliminates all17 database disk I/O, but limits data storage to the amount of18 available memory (and perhaps swap).19 </p></li><li class="listitem"><p>20 Turn off <a class="xref" href="runtime-config-wal.html#GUC-FSYNC">fsync</a>; there is no need to flush21 data to disk.22 </p></li><li class="listitem"><p>23 Turn off <a class="xref" href="runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT">synchronous_commit</a>; there might be no24 need to force <acronym class="acronym">WAL</acronym> writes to disk on every25 commit. This setting does risk transaction loss (though not data26 corruption) in case of a crash of the <span class="emphasis"><em>database</em></span>.27 </p></li><li class="listitem"><p>28 Turn off <a class="xref" href="runtime-config-wal.html#GUC-FULL-PAGE-WRITES">full_page_writes</a>; there is no need29 to guard against partial page writes.30 </p></li><li class="listitem"><p>31 Increase <a class="xref" href="runtime-config-wal.html#GUC-MAX-WAL-SIZE">max_wal_size</a> and <a class="xref" href="runtime-config-wal.html#GUC-CHECKPOINT-TIMEOUT">checkpoint_timeout</a>; this reduces the frequency32 of checkpoints, but increases the storage requirements of33 <code class="filename">/pg_wal</code>.34 </p></li><li class="listitem"><p>35 Create <a class="link" href="sql-createtable.html#SQL-CREATETABLE-UNLOGGED">unlogged36 tables</a> to avoid <acronym class="acronym">WAL</acronym> writes, though it37 makes the tables non-crash-safe.38 </p></li></ul></div><p>39 </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="populate.html" title="14.4. Populating a Database">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="performance-tips.html" title="Chapter 14. Performance Tips">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="parallel-query.html" title="Chapter 15. Parallel Query">Next</a></td></tr><tr><td width="40%" align="left" valign="top">14.4. Populating a Database </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> Chapter 15. Parallel Query</td></tr></table></div></body></html>