1
1
<!--
2
- $PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.349 2005/08/29 21:38:17 tgl Exp $
2
+ $PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.350 2005/08/30 00:58:47 tgl Exp $
3
3
-->
4
4
5
5
<chapter Id="runtime">
@@ -1161,7 +1161,7 @@ SET ENABLE_SEQSCAN TO OFF;
1161
1161
buffers is only a buffer descriptor, or about 64 bytes, per
1162
1162
increment in <varname>temp_buffers</>. However if a buffer is
1163
1163
actually used an additional 8192 bytes will be consumed for it
1164
- (or in general <symbol>BLCKSZ</symbol> bytes).
1164
+ (or in general, <symbol>BLCKSZ</symbol> bytes).
1165
1165
</para>
1166
1166
</listitem>
1167
1167
</varlistentry>
@@ -1183,6 +1183,14 @@ SET ENABLE_SEQSCAN TO OFF;
1183
1183
This option can only be set at server start.
1184
1184
</para>
1185
1185
1186
+ <para>
1187
+ If you are not using prepared transactions, this parameter may as
1188
+ well be set to zero. If you are using them, you will probably
1189
+ want <varname>max_prepared_transactions</varname> to be at least
1190
+ as large as <xref linkend="guc-max-connections">, to avoid unwanted
1191
+ failures at the prepare step.
1192
+ </para>
1193
+
1186
1194
<para>
1187
1195
Increasing this parameter may cause <productname>PostgreSQL</>
1188
1196
to request more <systemitem class="osname">System V</> shared
@@ -1267,6 +1275,32 @@ SET ENABLE_SEQSCAN TO OFF;
1267
1275
<sect3 id="runtime-config-resource-fsm">
1268
1276
<title>Free Space Map</title>
1269
1277
1278
+ <indexterm>
1279
+ <primary>free space map</primary>
1280
+ </indexterm>
1281
+
1282
+ <para>
1283
+ These parameters control the size of the shared <firstterm>free space
1284
+ map</>, which tracks the locations of unused space in the database.
1285
+ An undersized free space map may cause the database to consume
1286
+ increasing amounts of disk space over time, because free space that
1287
+ is not in the map cannot be re-used; instead <productname>PostgreSQL</>
1288
+ will request more disk space from the operating system when it needs
1289
+ to store new data.
1290
+ The last few lines displayed by a database-wide <command>VACUUM VERBOSE</>
1291
+ command can help in determining if the current settings are adequate.
1292
+ A <literal>NOTICE</> message is also printed during such an operation
1293
+ if the current settings are too low.
1294
+ </para>
1295
+
1296
+ <para>
1297
+ Increasing these parameters may cause <productname>PostgreSQL</>
1298
+ to request more <systemitem class="osname">System V</> shared
1299
+ memory than your operating system's default configuration
1300
+ allows. See <xref linkend="sysvipc"> for information on how to
1301
+ adjust those parameters, if necessary.
1302
+ </para>
1303
+
1270
1304
<variablelist>
1271
1305
<varlistentry id="guc-max-fsm-pages" xreflabel="max_fsm_pages">
1272
1306
<term><varname>max_fsm_pages</varname> (<type>integer</type>)</term>
@@ -1279,10 +1313,6 @@ SET ENABLE_SEQSCAN TO OFF;
1279
1313
be tracked in the shared free-space map. Six bytes of shared memory
1280
1314
are consumed for each page slot. This setting must be more than
1281
1315
16 * <varname>max_fsm_relations</varname>. The default is 20000.
1282
- The last few lines of a database-wide <command>VACUUM VERBOSE</>
1283
- can help in determining if the the default setting is suitable.
1284
- A <literal>NOTICE</> message is also printed during such an operation
1285
- if the current setting is too low.
1286
1316
This option can only be set at server start.
1287
1317
</para>
1288
1318
</listitem>
@@ -1297,12 +1327,8 @@ SET ENABLE_SEQSCAN TO OFF;
1297
1327
<para>
1298
1328
Sets the maximum number of relations (tables and indexes) for which
1299
1329
free space will be tracked in the shared free-space map. Roughly
1300
- fifty bytes of shared memory are consumed for each slot.
1330
+ seventy bytes of shared memory are consumed for each slot.
1301
1331
The default is 1000.
1302
- The last few lines of a database-wide <command>VACUUM VERBOSE</>
1303
- can help in determining if the the default setting is suitable.
1304
- A <literal>NOTICE</> message is also printed during such an operation
1305
- if the current setting is too low.
1306
1332
This option can only be set at server start.
1307
1333
</para>
1308
1334
</listitem>
@@ -1804,9 +1830,18 @@ SET ENABLE_SEQSCAN TO OFF;
1804
1830
<para>
1805
1831
Number of disk-page buffers allocated in shared memory for WAL data.
1806
1832
The default is 8. The setting need only be large enough to hold
1807
- the amount of WAL data generated by one typical transaction.
1833
+ the amount of WAL data generated by one typical transaction, since
1834
+ the data is flushed to disk at every transaction commit.
1808
1835
This option can only be set at server start.
1809
1836
</para>
1837
+
1838
+ <para>
1839
+ Increasing this parameter may cause <productname>PostgreSQL</>
1840
+ to request more <systemitem class="osname">System V</> shared
1841
+ memory than your operating system's default configuration
1842
+ allows. See <xref linkend="sysvipc"> for information on how to
1843
+ adjust those parameters, if necessary.
1844
+ </para>
1810
1845
</listitem>
1811
1846
</varlistentry>
1812
1847
@@ -3952,9 +3987,11 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
3952
3987
</indexterm>
3953
3988
<listitem>
3954
3989
<para>
3955
- The shared lock table issized on the assumption that at most
3990
+ The shared lock table iscreated with room to describe locks on
3956
3991
<varname>max_locks_per_transaction</varname> *
3957
- <varname>max_connections</varname> distinct objects will need to
3992
+ (<xref linkend="guc-max-connections"> +
3993
+ <xref linkend="guc-max-prepared-transactions">) objects;
3994
+ hence, no more than this many distinct objects can
3958
3995
be locked at any one time. (Thus, this parameter's name may be
3959
3996
confusing: it is not a hard limit on the number of locks taken
3960
3997
by any one transaction, but rather a maximum average value.)
@@ -3963,6 +4000,14 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
3963
4000
have clients that touch many different tables in a single
3964
4001
transaction. This option can only be set at server start.
3965
4002
</para>
4003
+
4004
+ <para>
4005
+ Increasing this parameter may cause <productname>PostgreSQL</>
4006
+ to request more <systemitem class="osname">System V</> shared
4007
+ memory than your operating system's default configuration
4008
+ allows. See <xref linkend="sysvipc"> for information on how to
4009
+ adjust those parameters, if necessary.
4010
+ </para>
3966
4011
</listitem>
3967
4012
</varlistentry>
3968
4013
@@ -4653,9 +4698,10 @@ $ <userinput>postmaster -o '-S 1024 -s'</userinput>
4653
4698
relevant for <productname>PostgreSQL</>). Almost all modern
4654
4699
operating systems provide these features, but not all of them have
4655
4700
them turned on or sufficiently sized by default, especially systems
4656
- with BSD heritage. (For the <systemitem class="osname">QNX</> and
4657
- <systemitem class="osname">BeOS</> ports, <productname>PostgreSQL</>
4658
- provides its own replacement implementation of these facilities.)
4701
+ with BSD heritage. (For the <systemitem class="osname">Windows</>,
4702
+ <systemitem class="osname">QNX</> and <systemitem class="osname">BeOS</>
4703
+ ports, <productname>PostgreSQL</> provides its own replacement
4704
+ implementation of these facilities.)
4659
4705
</para>
4660
4706
4661
4707
<para>
@@ -4695,8 +4741,7 @@ $ <userinput>postmaster -o '-S 1024 -s'</userinput>
4695
4741
<row>
4696
4742
<entry><varname>SHMMAX</></>
4697
4743
<entry>Maximum size of shared memory segment (bytes)</>
4698
- <entry>250 kB + 8.2 kB * <xref linkend="guc-shared-buffers"> +
4699
- 14.2 kB * <xref linkend="guc-max-connections"> up to infinity</entry>
4744
+ <entry>at least several megabytes (see text)</entry>
4700
4745
</row>
4701
4746
4702
4747
<row>
@@ -4764,14 +4809,17 @@ $ <userinput>postmaster -o '-S 1024 -s'</userinput>
4764
4809
bytes, of a shared memory segment. If you get an error message from
4765
4810
<function>shmget</> like <errorname>Invalid argument</>, it is
4766
4811
likely that this limit has been exceeded. The size of the required
4767
- shared memory segment varies both with the number of requested
4768
- buffers (<option>-B</> option) and the number of allowed connections
4769
- (<option>-N</> option), although the former is the most significant.
4770
- (You can, as a temporary solution, lower these settings to eliminate
4771
- the failure.) As a rough approximation, you can estimate the
4772
- required segment size as suggested in <xref
4773
- linkend="sysvipc-parameters">. Any error message you might get will
4774
- contain the size of the failed allocation request.
4812
+ shared memory segment varies depending on several
4813
+ <productname>PostgreSQL</> configuration parameters, as shown in
4814
+ <xref linkend="shared-memory-parameters">.
4815
+ You can, as a temporary solution, lower some of those settings to
4816
+ avoid the failure. As a rough approximation, you can estimate the
4817
+ required segment size as 500 kB plus the variable amounts shown in
4818
+ the table. (Any error message you might get will include the exact
4819
+ size of the failed allocation request.) While it is possible to get
4820
+ <productname>PostgreSQL</> to run with <varname>SHMMAX</> as small as
4821
+ 1 MB, you need at least 4 MB for acceptable performance, and desirable
4822
+ settings are in the tens of megabytes.
4775
4823
</para>
4776
4824
4777
4825
<para>
@@ -4785,16 +4833,16 @@ $ <userinput>postmaster -o '-S 1024 -s'</userinput>
4785
4833
<para>
4786
4834
Less likely to cause problems is the minimum size for shared
4787
4835
memory segments (<varname>SHMMIN</>), which should be at most
4788
- approximately256 kB for <productname>PostgreSQL</> (it is
4836
+ approximately500 kB for <productname>PostgreSQL</> (it is
4789
4837
usually just 1). The maximum number of segments system-wide
4790
4838
(<varname>SHMMNI</>) or per-process (<varname>SHMSEG</>) are unlikely
4791
4839
to cause a problem unless your system has them set to zero.
4792
4840
</para>
4793
4841
4794
4842
<para>
4795
4843
<productname>PostgreSQL</> uses one semaphore per allowed connection
4796
- (<option>-N</> option ), in sets of 16. Each such set will also
4797
- contain a 17th semaphore which contains a <quote>magic
4844
+ (<xref linkend="guc-max-connections"> ), in sets of 16. Each such set will
4845
+ also contain a 17th semaphore which contains a <quote>magic
4798
4846
number</quote>, to detect collision with semaphore sets used by
4799
4847
other applications. The maximum number of semaphores in the system
4800
4848
is set by <varname>SEMMNS</>, which consequently must be at least
@@ -4834,6 +4882,7 @@ $ <userinput>postmaster -o '-S 1024 -s'</userinput>
4834
4882
for <productname>PostgreSQL</>.
4835
4883
</para>
4836
4884
4885
+
4837
4886
<variablelist>
4838
4887
4839
4888
<varlistentry>
@@ -5172,6 +5221,59 @@ set semsys:seminfo_semmsl=32
5172
5221
</varlistentry>
5173
5222
5174
5223
</variablelist>
5224
+
5225
+
5226
+ <table id="shared-memory-parameters">
5227
+ <title>Configuration parameters affecting
5228
+ <productname>PostgreSQL</productname>'s shared memory usage</>
5229
+
5230
+ <tgroup cols="2">
5231
+ <thead>
5232
+ <row>
5233
+ <entry>Name</>
5234
+ <entry>Approximate multiplier (bytes per increment)</>
5235
+ </row>
5236
+ </thead>
5237
+
5238
+ <tbody>
5239
+ <row>
5240
+ <entry><xref linkend="guc-max-connections"></>
5241
+ <entry>400 (but see also <varname>max_locks_per_transaction</>)</entry>
5242
+ </row>
5243
+
5244
+ <row>
5245
+ <entry><xref linkend="guc-max-prepared-transactions"></>
5246
+ <entry>600 (but see also <varname>max_locks_per_transaction</>)</entry>
5247
+ </row>
5248
+
5249
+ <row>
5250
+ <entry><xref linkend="guc-max-locks-per-transaction"></>
5251
+ <entry>220 * (<xref linkend="guc-max-connections"> +
5252
+ <xref linkend="guc-max-prepared-transactions">)</>
5253
+ </row>
5254
+
5255
+ <row>
5256
+ <entry><xref linkend="guc-shared-buffers"></>
5257
+ <entry>8300</>
5258
+ </row>
5259
+
5260
+ <row>
5261
+ <entry><xref linkend="guc-wal-buffers"></>
5262
+ <entry>8200</>
5263
+ </row>
5264
+
5265
+ <row>
5266
+ <entry><xref linkend="guc-max-fsm-relations"></>
5267
+ <entry>70</>
5268
+ </row>
5269
+
5270
+ <row>
5271
+ <entry><xref linkend="guc-max-fsm-pages"></>
5272
+ <entry>6</>
5273
+ </row>
5274
+ </tbody>
5275
+ </tgroup>
5276
+ </table>
5175
5277
</sect2>
5176
5278
5177
5279