postgres-ref.sgml 13.3 KB
Newer Older
1
<!--
2
$Header: /cvsroot/pgsql/doc/src/sgml/ref/postgres-ref.sgml,v 1.7 2000/03/27 17:14:43 thomas Exp $
3 4 5
Postgres documentation
-->

T
Thomas G. Lockhart 已提交
6 7
<refentry id="APP-POSTGRES">
 <refmeta>
8
  <refentrytitle id="APP-POSTGRES-TITLE">
T
Thomas G. Lockhart 已提交
9 10 11 12 13
   <application>postgres</application>
  </refentrytitle>
  <refmiscinfo>Application</refmiscinfo>
 </refmeta>
 <refnamediv>
14
  <refname>
T
Thomas G. Lockhart 已提交
15 16 17 18 19 20 21 22
   <application>postgres</application>
  </refname>
  <refpurpose>
   Run a <productname>Postgres</productname> single-user backend
  </refpurpose>
 </refnamediv>
 <refsynopsisdiv>
  <refsynopsisdivinfo>
23
   <date>1999-07-20</date>
T
Thomas G. Lockhart 已提交
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
  </refsynopsisdivinfo>
  <synopsis>
postgres [ <replaceable class="parameter">dbname</replaceable> ]
postgres [ -B <replaceable class="parameter">nBuffers</replaceable> ] [ -C ] [ -D <replaceable class="parameter">DataDir</replaceable> ] [ -E ] [ -F ]
   [ -O ] [ -Q ] [ -S <replaceable class="parameter">SortSize</replaceable> ] [ -d [ <replaceable class="parameter">DebugLevel</replaceable> ] ] [ -e ]
   [ -o ] [ <replaceable class="parameter">OutputFile</replaceable> ] [ -s ] [ -v <replaceable class="parameter">protocol</replaceable> ] [ <replaceable class="parameter">dbname</replaceable> ]
  </synopsis>

  <refsect2 id="R2-APP-POSTGRES-1">
   <refsect2info>
    <date>1999-05-19</date>
   </refsect2info>
   <title>
    Inputs
   </title>
   <para>
    <application>postgres</application> accepts the following command line arguments:
    
    <variablelist>
     <varlistentry>
44
      <term><replaceable class="parameter">dbname</replaceable></term>
T
Thomas G. Lockhart 已提交
45 46 47 48 49 50 51 52 53 54 55 56 57 58
      <listitem>
       <para>
	The optional argument
	<replaceable class="parameter">dbname</replaceable>
	specifies the name of the database to be accessed.
	<replaceable class="parameter">dbname</replaceable>
	defaults to the value of the
	<envar>USER</envar>
	environment variable.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
59
      <term>-B <replaceable class="parameter">nBuffers</replaceable></term>
T
Thomas G. Lockhart 已提交
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
      <listitem>
       <para>
	If the backend is running under the 
	<application>postmaster</application>,
	<replaceable class="parameter">nBuffers</replaceable>
	is the number of shared-memory buffers that the
	<application>postmaster</application>
	has allocated for the backend server processes that it starts.  If the
	backend is running standalone, this specifies the number of buffers to
	allocate.  This value defaults to 64 buffers, where each buffer is 8k bytes
	(or whatever BLCKSZ is set to in config.h).
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
76
      <term>-C</term>
T
Thomas G. Lockhart 已提交
77 78 79 80 81 82 83 84
      <listitem>
       <para>
	Do not show the server version number.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
85
      <term>-D <replaceable class="parameter">DataDir</replaceable></term>
T
Thomas G. Lockhart 已提交
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
      <listitem>
       <para>
	Specifies the directory to use as the root of the tree of database
	directories.  If -D is not given, the default data directory name is
	the value of the environment variable 
	<envar>PGDATA</envar>.
	If <envar>PGDATA</envar> is not set, then the directory used is
	<filename>$POSTGRESHOME/data</filename>.
	If neither environment variable is set and this command-line
	option is not specified, the default directory that was
	set at compile-time is used.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
102
      <term>-E</term>
T
Thomas G. Lockhart 已提交
103 104 105 106 107 108 109 110
      <listitem>
       <para>
	Echo all queries.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
111
      <term>-F</term>
T
Thomas G. Lockhart 已提交
112 113 114 115 116 117 118 119 120 121 122 123
      <listitem>
       <para>
	Disable an automatic <function>fsync()</function> call after each transaction.
	This option improves performance, but an operating system crash
	while a transaction is in progress may  cause the loss of
	the most recently entered data. Without the <function>fsync()</function> call
	the data is buffered by the operating system, and written to disk sometime later.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
124
      <term>-O</term>
T
Thomas G. Lockhart 已提交
125 126 127 128 129 130 131 132 133
      <listitem>
       <para>
	Override restrictions, so system table structures can be modified.
	These tables are typically those with a leading "pg_" in the table name.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
134
      <term>-Q</term>
T
Thomas G. Lockhart 已提交
135 136 137 138 139 140 141 142
      <listitem>
       <para>
	Specifies "quiet" mode.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
143
      <term>-S <replaceable class="parameter">SortSize</replaceable></term>
T
Thomas G. Lockhart 已提交
144 145 146 147 148 149 150 151 152 153 154 155 156 157
      <listitem>
       <para>
	Specifies the amount of memory to be used by internal sorts and hashes
	before resorting to temporary disk files.  The value is specified in
	kilobytes, and defaults to 512 kilobytes.  Note that for a complex query,
	several sorts and/or hashes might be running in parallel, and each one
	will be allowed to use as much as
	<replaceable class="parameter">SortSize</replaceable> kilobytes
	before it starts to put data into temporary files.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
158
      <term>-d [ <replaceable class="parameter">DebugLevel</replaceable> ]</term>
T
Thomas G. Lockhart 已提交
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
      <listitem>
       <para>
	The optional argument <replaceable class="parameter">DebugLevel</replaceable>
	determines the amount of debugging output the backend servers will
	produce.
	If <replaceable class="parameter">DebugLevel</replaceable>
	is one, the postmaster will trace all connection traffic,
	and nothing else.
	For levels two and higher,
	debugging is turned on in the backend process and the postmaster
	displays more information,
	including the backend environment and process traffic.
	Note that if no file is specified for backend servers to
	send their debugging output then this output will appear on the
	controlling tty of their parent <application>postmaster</application>.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
179
      <term>-e</term>
T
Thomas G. Lockhart 已提交
180 181 182 183 184 185 186 187 188 189 190 191
      <listitem>
       <para>
	This option controls how dates are interpreted upon
	input to and output from the database.
	If the <option>-e</option>
	option is supplied, then dates passed to and from the frontend
	processes will be assumed to be in "European"
	format (<literal>DD-MM-YYYY</literal>),
	otherwise dates are assumed to be in
	"American" format (<literal>MM-DD-YYYY</literal>).
	Dates are accepted by the backend in a wide variety of formats,
	and for input dates this switch mostly affects the interpretation
T
Thomas G. Lockhart 已提交
192
	for ambiguous cases.
193
	See the <citetitle>PostgreSQL User's Guide</citetitle>
T
Thomas G. Lockhart 已提交
194 195 196 197 198 199
	for more information.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
200
      <term>-o <replaceable class="parameter">OutputFile</replaceable></term>
T
Thomas G. Lockhart 已提交
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
      <listitem>
       <para>
	Sends all debugging and error output to 
	<replaceable class="parameter">OutputFile</replaceable>.
	If the backend is running under the <application>postmaster</application>,
	error messages are still sent to the frontend process as well as to
	<replaceable class="parameter">OutputFile</replaceable>,
	but debugging output is sent to the controlling tty of the
	<application>postmaster</application>
	(since only one file descriptor can be sent to an actual file).
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
216
      <term>-s</term>
T
Thomas G. Lockhart 已提交
217 218 219 220 221 222 223 224 225 226
      <listitem>
       <para>
	Print time information and other statistics at the end of each query.
	This is useful for benchmarking or for use in tuning the number of
	buffers.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
227
      <term>-v <replaceable class="parameter">protocol</replaceable></term>
T
Thomas G. Lockhart 已提交
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250
      <listitem>
       <para>
	Specifies the number of the frontend/backend protocol to be used for this
	particular session.
       </para>
      </listitem>
     </varlistentry>
    </variablelist>
   </para>

   <para>
    There are several other options that may be specified, used mainly
    for debugging purposes.  These are listed here only for the use by
    <productname>Postgres</productname> system developers.
    <emphasis>Use of any of these options is highly discouraged.</emphasis>
    Furthermore, any of these options may disappear or change at any time.
   </para>

   <para>
    These special-case options are:

    <variablelist>
     <varlistentry>
251
      <term>-A n|r|b|Q\fIn\fP|X\fIn\fP</term>
T
Thomas G. Lockhart 已提交
252 253 254 255 256 257 258 259
      <listitem>
       <para>
	This option generates a tremendous amount of output.
       </para>
     </listitem>
    </varlistentry>

     <varlistentry>
260
      <term>-L</term>
T
Thomas G. Lockhart 已提交
261 262 263 264 265 266 267 268
      <listitem>
       <para>
	Turns off the locking system.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
269
      <term>-N</term>
T
Thomas G. Lockhart 已提交
270 271 272 273 274 275 276 277
      <listitem>
       <para>
	Disables use of newline as a query delimiter.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
278
      <term>-f [ s | i | m | n | h ]</term>
T
Thomas G. Lockhart 已提交
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299
      <listitem>
       <para>
	Forbids the use of particular scan and join methods:
	<literal>s</literal> and <literal>i</literal>
	disable sequential and index scans respectively, while
	<literal>n</literal>, <literal>m</literal>, and <literal>h</literal>
	disable nested-loop, merge and hash joins respectively.
	
	<note>
	 <para>
	  Neither sequential scans nor nested-loop joins can be disabled completely;
	  the <literal>-fs</literal> and <literal>-fn</literal>
	  options simply discourage the optimizer from using those
	  plan types if it has any other alternative.
	 </para>
	</note>
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
300
      <term>-i</term>
T
Thomas G. Lockhart 已提交
301 302 303 304 305 306 307 308
      <listitem>
       <para>
	Prevents query execution, but shows the plan tree.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
309
      <term>-p <replaceable class="parameter">dbname</replaceable></term>
T
Thomas G. Lockhart 已提交
310 311 312 313 314 315 316 317 318 319 320 321
      <listitem>
       <para>
	Indicates to the backend server that it has been started by a 
	<application>postmaster</application>
	and make different assumptions about buffer pool management, file
	descriptors, etc.  Switches following -p are restricted to those
	considered "secure".
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
322
      <term>-t pa[rser] | pl[anner] | e[xecutor]</term>
T
Thomas G. Lockhart 已提交
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346
      <listitem>
       <para>
	Print timing statistics for each query relating to each of the major
	system modules.  This option cannot be used with <option>-s</option>.
       </para>
      </listitem>
     </varlistentry>
    </variablelist>
   </para>
  </refsect2>

  <refsect2 id="R2-APP-POSTGRES-2">
   <refsect2info>
    <date>1999-05-19</date>
   </refsect2info>
   <title>
    Outputs
   </title>
   <para>
    Of the nigh-infinite number of error messages you may see when you
    execute the backend server directly, the most common will probably be:

    <variablelist>
     <varlistentry>
347 348 349
      <term><computeroutput>
semget: No space left on device
       </computeroutput></term>
T
Thomas G. Lockhart 已提交
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422
      <listitem>
       <para>
	If you see this message, you should run the
	<application>ipcclean</application>
	command.  After doing this, try starting
	<application>postmaster</application>
	again.  If this still doesn't work, you probably need to configure
	your kernel for shared memory and semaphores as described in the
	installation notes.  If you have a kernel with particularly small shared memory
	and/or semaphore limits, you may have to reconfigure your kernel to increase
	its shared memory or semaphore parameters.

	<tip>
	 <para>
	  You may be able to postpone
	  reconfiguring your kernel by decreasing -B to reduce
	  <productname>Postgres</productname>' shared memory
	  consumption.
	 </para>
	</tip>
       </para>
      </listitem>
     </varlistentry>
    </variablelist>
   </para>
  </refsect2>
 </refsynopsisdiv>

 <refsect1 id="R1-APP-POSTGRES-1">
  <refsect1info>
   <date>1999-05-19</date>
  </refsect1info>
  <title>
   Description
  </title>

  <para>
   The Postgres backend server can be executed directly from the user shell.
   This should be done only while debugging by the DBA, and should not be
   done while other Postgres backends are being managed by a
   <application>postmaster</application>
   on this set of databases.
  </para>

  <para>
   Some of the switches explained here can be passed to the backend
   through the "database options" field of a connection request, and thus can be
   set for a particular backend without going to the trouble of restarting the
   postmaster.  This is particularly handy for debugging-related switches.
  </para>

  <para>
   The optional argument <replaceable class="parameter">dbname</replaceable>
   specifies the name of the database to be accessed.
   <replaceable class="parameter">dbname</replaceable>
   defaults to the value of the
   <envar>USER</envar> environment variable.
  </para>
 </refsect1>

 <refsect1 id="R1-APP-POSTGRES-2">
  <refsect1info>
   <date>1998-10-04</date>
  </refsect1info>
  <title>
   Notes
  </title>
  
  <para>
   Useful utilities for dealing with shared memory problems include
   <application>ipcs(1)</application>,
   <application>ipcrm(1</application>), and
   <application>ipcclean(1)</application>.
423
   See also <xref linkend="app-postmaster" endterm="app-postmaster-title">.
T
Thomas G. Lockhart 已提交
424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443
  </para>
 </refsect1>
</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:nil
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"../reference.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:"/usr/lib/sgml/catalog"
sgml-local-ecat-files:nil
End:
-->