1- <!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.59 2006/05/21 20:10:42 tgl Exp $ -->
1+ <!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.60 2006/06/05 02:49:58 tgl Exp $ -->
22
33<chapter Id="runtime-config">
44 <title>Server Configuration</title>
@@ -1739,40 +1739,39 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows
17391739 Planner Cost Constants
17401740 </title>
17411741
1742+ <para>
1743+ The <firstterm>cost</> variables described in this section are measured
1744+ on an arbitrary scale. Only their relative values matter, hence
1745+ scaling them all up or down by the same factor will result in no change
1746+ in the planner's choices. Traditionally, these variables have been
1747+ referenced to sequential page fetches as the unit of cost; that is,
1748+ <varname>seq_page_cost</> is conventionally set to <literal>1.0</>
1749+ and the other cost variables are set with reference to that. But
1750+ you can use a different scale if you prefer, such as actual execution
1751+ times in milliseconds on a particular machine.
1752+ </para>
1753+
17421754 <note>
17431755 <para>
1744- Unfortunately, there is no well-defined method for determining
1745- ideal values for the family of <quote>cost</quote> variables that
1746- appear below. You are encouraged to experiment and share
1747- your findings.
1756+ Unfortunately, there is no well-defined method for determining ideal
1757+ values for the cost variables. They are best treated as averages over
1758+ the entire mix of queries that a particular installation will get. This
1759+ means that changing them on the basis of just a few experiments is very
1760+ risky.
17481761 </para>
17491762 </note>
17501763
17511764 <variablelist>
1752-
1753- <varlistentry id="guc-effective-cache-size " xreflabel="effective_cache_size ">
1754- <term><varname>effective_cache_size </varname> (<type>floating point</type>)</term>
1765+
1766+ <varlistentry id="guc-seq-page-cost " xreflabel="seq_page_cost ">
1767+ <term><varname>seq_page_cost </varname> (<type>floating point</type>)</term>
17551768 <indexterm>
1756- <primary><varname>effective_cache_size </> configuration parameter</primary>
1769+ <primary><varname>seq_page_cost </> configuration parameter</primary>
17571770 </indexterm>
17581771 <listitem>
17591772 <para>
1760- Sets the planner's assumption about the effective size of the
1761- disk cache that is available to a single index scan. This is
1762- factored into estimates of the cost of using an index; a
1763- higher value makes it more likely index scans will be used, a
1764- lower value makes it more likely sequential scans will be
1765- used. When setting this parameter you should consider both
1766- <productname>PostgreSQL</productname>'s shared buffers and the
1767- portion of the kernel's disk cache that will be used for
1768- <productname>PostgreSQL</productname> data files. Also, take
1769- into account the expected number of concurrent queries using
1770- different indexes, since they will have to share the available
1771- space. This parameter has no effect on the size of shared
1772- memory allocated by <productname>PostgreSQL</productname>, nor
1773- does it reserve kernel disk cache; it is used only for
1774- estimation purposes. The value is measured in disk pages,
1775- which are normally 8192 bytes each. The default is 1000.
1773+ Sets the planner's estimate of the cost of a disk page fetch
1774+ that is part of a series of sequential fetches. The default is 1.0.
17761775 </para>
17771776 </listitem>
17781777 </varlistentry>
@@ -1785,12 +1784,27 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows
17851784 <listitem>
17861785 <para>
17871786 Sets the planner's estimate of the cost of a
1788- nonsequentially fetched disk page. This is measured as a
1789- multiple of the cost of a sequential page fetch. A higher
1790- value makes it more likely a sequential scan will be used, a
1791- lower value makes it more likely an index scan will be
1792- used. The default is four.
1787+ non-sequentially-fetched disk page. The default is 4.0.
1788+ Reducing this value relative to <varname>seq_page_cost</>
1789+ will cause the system to prefer index scans; raising it will
1790+ make index scans look relatively more expensive. You can raise
1791+ or lower both values together to change the importance of disk I/O
1792+ costs relative to CPU costs, which are described by the following
1793+ parameters.
17931794 </para>
1795+
1796+ <tip>
1797+ <para>
1798+ Although the system will let you set <varname>random_page_cost</> to
1799+ less than <varname>seq_page_cost</>, it is not physically sensible
1800+ to do so. However, setting them equal makes sense if the database
1801+ is entirely cached in RAM, since in that case there is no penalty
1802+ for touching pages out of sequence. Also, in a heavily-cached
1803+ database you should lower both values relative to the CPU parameters,
1804+ since the cost of fetching a page already in RAM is much smaller
1805+ than it would normally be.
1806+ </para>
1807+ </tip>
17941808 </listitem>
17951809 </varlistentry>
17961810
@@ -1802,8 +1816,8 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows
18021816 <listitem>
18031817 <para>
18041818 Sets the planner's estimate of the cost of processing
1805- each row during a query. This is measured as a fraction of
1806- the cost of a sequential page fetch. The default is 0.01.
1819+ each row during a query.
1820+ The default is 0.01.
18071821 </para>
18081822 </listitem>
18091823 </varlistentry>
@@ -1816,9 +1830,8 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows
18161830 <listitem>
18171831 <para>
18181832 Sets the planner's estimate of the cost of processing
1819- each index row during an index scan. This is measured as a
1820- fraction of the cost of a sequential page fetch. The default
1821- is 0.001.
1833+ each index entry during an index scan.
1834+ The default is 0.001.
18221835 </para>
18231836 </listitem>
18241837 </varlistentry>
@@ -1831,8 +1844,35 @@ archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Windows
18311844 <listitem>
18321845 <para>
18331846 Sets the planner's estimate of the cost of processing each
1834- operator in a <literal>WHERE</> clause. This is measured as a fraction of
1835- the cost of a sequential page fetch. The default is 0.0025.
1847+ operator or function executed during a query.
1848+ The default is 0.0025.
1849+ </para>
1850+ </listitem>
1851+ </varlistentry>
1852+
1853+ <varlistentry id="guc-effective-cache-size" xreflabel="effective_cache_size">
1854+ <term><varname>effective_cache_size</varname> (<type>floating point</type>)</term>
1855+ <indexterm>
1856+ <primary><varname>effective_cache_size</> configuration parameter</primary>
1857+ </indexterm>
1858+ <listitem>
1859+ <para>
1860+ Sets the planner's assumption about the effective size of the
1861+ disk cache that is available to a single index scan. This is
1862+ factored into estimates of the cost of using an index; a
1863+ higher value makes it more likely index scans will be used, a
1864+ lower value makes it more likely sequential scans will be
1865+ used. When setting this parameter you should consider both
1866+ <productname>PostgreSQL</productname>'s shared buffers and the
1867+ portion of the kernel's disk cache that will be used for
1868+ <productname>PostgreSQL</productname> data files. Also, take
1869+ into account the expected number of concurrent queries using
1870+ different indexes, since they will have to share the available
1871+ space. This parameter has no effect on the size of shared
1872+ memory allocated by <productname>PostgreSQL</productname>, nor
1873+ does it reserve kernel disk cache; it is used only for
1874+ estimation purposes. The value is measured in disk pages,
1875+ which are normally 8192 bytes each. The default is 1000.
18361876 </para>
18371877 </listitem>
18381878 </varlistentry>