1<!-- doc/src/sgml/config.sgml --> 2 3<chapter id="runtime-config"> 4 <title>Server Configuration</title> 5 6 <indexterm> 7 <primary>configuration</primary> 8 <secondary>of the server</secondary> 9 </indexterm> 10 11 <para> 12 There are many configuration parameters that affect the behavior of 13 the database system. In the first section of this chapter we 14 describe how to interact with configuration parameters. The subsequent sections 15 discuss each parameter in detail. 16 </para> 17 18 <sect1 id="config-setting"> 19 <title>Setting Parameters</title> 20 21 <sect2 id="config-setting-names-values"> 22 <title>Parameter Names and Values</title> 23 24 <para> 25 All parameter names are case-insensitive. Every parameter takes a 26 value of one of five types: boolean, string, integer, floating point, 27 or enumerated (enum). The type determines the syntax for setting the 28 parameter: 29 </para> 30 31 <itemizedlist> 32 <listitem> 33 <para> 34 <emphasis>Boolean:</emphasis> 35 Values can be written as 36 <literal>on</literal>, 37 <literal>off</literal>, 38 <literal>true</literal>, 39 <literal>false</literal>, 40 <literal>yes</literal>, 41 <literal>no</literal>, 42 <literal>1</literal>, 43 <literal>0</literal> 44 (all case-insensitive) or any unambiguous prefix of one of these. 45 </para> 46 </listitem> 47 48 <listitem> 49 <para> 50 <emphasis>String:</emphasis> 51 In general, enclose the value in single quotes, doubling any single 52 quotes within the value. Quotes can usually be omitted if the value 53 is a simple number or identifier, however. 54 (Values that match a SQL keyword require quoting in some contexts.) 55 </para> 56 </listitem> 57 58 <listitem> 59 <para> 60 <emphasis>Numeric (integer and floating point):</emphasis> 61 Numeric parameters can be specified in the customary integer and 62 floating-point formats; fractional values are rounded to the nearest 63 integer if the parameter is of integer type. Integer parameters 64 additionally accept hexadecimal input (beginning 65 with <literal>0x</literal>) and octal input (beginning 66 with <literal>0</literal>), but these formats cannot have a fraction. 67 Do not use thousands separators. 68 Quotes are not required, except for hexadecimal input. 69 </para> 70 </listitem> 71 72 <listitem> 73 <para> 74 <emphasis>Numeric with Unit:</emphasis> 75 Some numeric parameters have an implicit unit, because they describe 76 quantities of memory or time. The unit might be bytes, kilobytes, blocks 77 (typically eight kilobytes), milliseconds, seconds, or minutes. 78 An unadorned numeric value for one of these settings will use the 79 setting's default unit, which can be learned from 80 <structname>pg_settings</structname>.<structfield>unit</structfield>. 81 For convenience, settings can be given with a unit specified explicitly, 82 for example <literal>'120 ms'</literal> for a time value, and they will be 83 converted to whatever the parameter's actual unit is. Note that the 84 value must be written as a string (with quotes) to use this feature. 85 The unit name is case-sensitive, and there can be whitespace between 86 the numeric value and the unit. 87 88 <itemizedlist> 89 <listitem> 90 <para> 91 Valid memory units are <literal>B</literal> (bytes), 92 <literal>kB</literal> (kilobytes), 93 <literal>MB</literal> (megabytes), <literal>GB</literal> 94 (gigabytes), and <literal>TB</literal> (terabytes). 95 The multiplier for memory units is 1024, not 1000. 96 </para> 97 </listitem> 98 99 <listitem> 100 <para> 101 Valid time units are 102 <literal>us</literal> (microseconds), 103 <literal>ms</literal> (milliseconds), 104 <literal>s</literal> (seconds), <literal>min</literal> (minutes), 105 <literal>h</literal> (hours), and <literal>d</literal> (days). 106 </para> 107 </listitem> 108 </itemizedlist> 109 110 If a fractional value is specified with a unit, it will be rounded 111 to a multiple of the next smaller unit if there is one. 112 For example, <literal>30.1 GB</literal> will be converted 113 to <literal>30822 MB</literal> not <literal>32319628902 B</literal>. 114 If the parameter is of integer type, a final rounding to integer 115 occurs after any unit conversion. 116 </para> 117 </listitem> 118 119 <listitem> 120 <para> 121 <emphasis>Enumerated:</emphasis> 122 Enumerated-type parameters are written in the same way as string 123 parameters, but are restricted to have one of a limited set of 124 values. The values allowable for such a parameter can be found from 125 <structname>pg_settings</structname>.<structfield>enumvals</structfield>. 126 Enum parameter values are case-insensitive. 127 </para> 128 </listitem> 129 </itemizedlist> 130 </sect2> 131 132 <sect2 id="config-setting-configuration-file"> 133 <title>Parameter Interaction via the Configuration File</title> 134 135 <para> 136 The most fundamental way to set these parameters is to edit the file 137 <filename>postgresql.conf</filename><indexterm><primary>postgresql.conf</primary></indexterm>, 138 which is normally kept in the data directory. A default copy is 139 installed when the database cluster directory is initialized. 140 An example of what this file might look like is: 141<programlisting> 142# This is a comment 143log_connections = yes 144log_destination = 'syslog' 145search_path = '"$user", public' 146shared_buffers = 128MB 147</programlisting> 148 One parameter is specified per line. The equal sign between name and 149 value is optional. Whitespace is insignificant (except within a quoted 150 parameter value) and blank lines are 151 ignored. Hash marks (<literal>#</literal>) designate the remainder 152 of the line as a comment. Parameter values that are not simple 153 identifiers or numbers must be single-quoted. To embed a single 154 quote in a parameter value, write either two quotes (preferred) 155 or backslash-quote. 156 If the file contains multiple entries for the same parameter, 157 all but the last one are ignored. 158 </para> 159 160 <para> 161 Parameters set in this way provide default values for the cluster. 162 The settings seen by active sessions will be these values unless they 163 are overridden. The following sections describe ways in which the 164 administrator or user can override these defaults. 165 </para> 166 167 <para> 168 <indexterm> 169 <primary>SIGHUP</primary> 170 </indexterm> 171 The configuration file is reread whenever the main server process 172 receives a <systemitem>SIGHUP</systemitem> signal; this signal is most easily 173 sent by running <literal>pg_ctl reload</literal> from the command line or by 174 calling the SQL function <function>pg_reload_conf()</function>. The main 175 server process also propagates this signal to all currently running 176 server processes, so that existing sessions also adopt the new values 177 (this will happen after they complete any currently-executing client 178 command). Alternatively, you can 179 send the signal to a single server process directly. Some parameters 180 can only be set at server start; any changes to their entries in the 181 configuration file will be ignored until the server is restarted. 182 Invalid parameter settings in the configuration file are likewise 183 ignored (but logged) during <systemitem>SIGHUP</systemitem> processing. 184 </para> 185 186 <para> 187 In addition to <filename>postgresql.conf</filename>, 188 a <productname>PostgreSQL</productname> data directory contains a file 189 <filename>postgresql.auto.conf</filename><indexterm><primary>postgresql.auto.conf</primary></indexterm>, 190 which has the same format as <filename>postgresql.conf</filename> but 191 is intended to be edited automatically, not manually. This file holds 192 settings provided through the <xref linkend="sql-altersystem"/> command. 193 This file is read whenever <filename>postgresql.conf</filename> is, 194 and its settings take effect in the same way. Settings 195 in <filename>postgresql.auto.conf</filename> override those 196 in <filename>postgresql.conf</filename>. 197 </para> 198 199 <para> 200 External tools may also 201 modify <filename>postgresql.auto.conf</filename>. It is not 202 recommended to do this while the server is running, since a 203 concurrent <command>ALTER SYSTEM</command> command could overwrite 204 such changes. Such tools might simply append new settings to the end, 205 or they might choose to remove duplicate settings and/or comments 206 (as <command>ALTER SYSTEM</command> will). 207 </para> 208 209 <para> 210 The system view 211 <link linkend="view-pg-file-settings"><structname>pg_file_settings</structname></link> 212 can be helpful for pre-testing changes to the configuration files, or for 213 diagnosing problems if a <systemitem>SIGHUP</systemitem> signal did not have the 214 desired effects. 215 </para> 216 </sect2> 217 218 <sect2 id="config-setting-sql-command-interaction"> 219 <title>Parameter Interaction via SQL</title> 220 221 <para> 222 <productname>PostgreSQL</productname> provides three SQL 223 commands to establish configuration defaults. 224 The already-mentioned <xref linkend="sql-altersystem"/> command 225 provides a SQL-accessible means of changing global defaults; it is 226 functionally equivalent to editing <filename>postgresql.conf</filename>. 227 In addition, there are two commands that allow setting of defaults 228 on a per-database or per-role basis: 229 </para> 230 231 <itemizedlist> 232 <listitem> 233 <para> 234 The <xref linkend="sql-alterdatabase"/> command allows global 235 settings to be overridden on a per-database basis. 236 </para> 237 </listitem> 238 239 <listitem> 240 <para> 241 The <xref linkend="sql-alterrole"/> command allows both global and 242 per-database settings to be overridden with user-specific values. 243 </para> 244 </listitem> 245 </itemizedlist> 246 247 <para> 248 Values set with <command>ALTER DATABASE</command> and <command>ALTER ROLE</command> 249 are applied only when starting a fresh database session. They 250 override values obtained from the configuration files or server 251 command line, and constitute defaults for the rest of the session. 252 Note that some settings cannot be changed after server start, and 253 so cannot be set with these commands (or the ones listed below). 254 </para> 255 256 <para> 257 Once a client is connected to the database, <productname>PostgreSQL</productname> 258 provides two additional SQL commands (and equivalent functions) to 259 interact with session-local configuration settings: 260 </para> 261 262 <itemizedlist> 263 <listitem> 264 <para> 265 The <xref linkend="sql-show"/> command allows inspection of the 266 current value of any parameter. The corresponding SQL function is 267 <function>current_setting(setting_name text)</function> 268 (see <xref linkend="functions-admin-set"/>). 269 </para> 270 </listitem> 271 272 <listitem> 273 <para> 274 The <xref linkend="sql-set"/> command allows modification of the 275 current value of those parameters that can be set locally to a 276 session; it has no effect on other sessions. 277 The corresponding SQL function is 278 <function>set_config(setting_name, new_value, is_local)</function> 279 (see <xref linkend="functions-admin-set"/>). 280 </para> 281 </listitem> 282 </itemizedlist> 283 284 <para> 285 In addition, the system view <link 286 linkend="view-pg-settings"><structname>pg_settings</structname></link> can be 287 used to view and change session-local values: 288 </para> 289 290 <itemizedlist> 291 <listitem> 292 <para> 293 Querying this view is similar to using <command>SHOW ALL</command> but 294 provides more detail. It is also more flexible, since it's possible 295 to specify filter conditions or join against other relations. 296 </para> 297 </listitem> 298 299 <listitem> 300 <para> 301 Using <xref linkend="sql-update"/> on this view, specifically 302 updating the <structname>setting</structname> column, is the equivalent 303 of issuing <command>SET</command> commands. For example, the equivalent of 304<programlisting> 305SET configuration_parameter TO DEFAULT; 306</programlisting> 307 is: 308<programlisting> 309UPDATE pg_settings SET setting = reset_val WHERE name = 'configuration_parameter'; 310</programlisting> 311 </para> 312 </listitem> 313 </itemizedlist> 314 315 </sect2> 316 317 <sect2> 318 <title>Parameter Interaction via the Shell</title> 319 320 <para> 321 In addition to setting global defaults or attaching 322 overrides at the database or role level, you can pass settings to 323 <productname>PostgreSQL</productname> via shell facilities. 324 Both the server and <application>libpq</application> client library 325 accept parameter values via the shell. 326 </para> 327 328 <itemizedlist> 329 <listitem> 330 <para> 331 During server startup, parameter settings can be 332 passed to the <command>postgres</command> command via the 333 <option>-c</option> command-line parameter. For example, 334<programlisting> 335postgres -c log_connections=yes -c log_destination='syslog' 336</programlisting> 337 Settings provided in this way override those set via 338 <filename>postgresql.conf</filename> or <command>ALTER SYSTEM</command>, 339 so they cannot be changed globally without restarting the server. 340 </para> 341 </listitem> 342 343 <listitem> 344 <para> 345 When starting a client session via <application>libpq</application>, 346 parameter settings can be 347 specified using the <envar>PGOPTIONS</envar> environment variable. 348 Settings established in this way constitute defaults for the life 349 of the session, but do not affect other sessions. 350 For historical reasons, the format of <envar>PGOPTIONS</envar> is 351 similar to that used when launching the <command>postgres</command> 352 command; specifically, the <option>-c</option> flag must be specified. 353 For example, 354<programlisting> 355env PGOPTIONS="-c geqo=off -c statement_timeout=5min" psql 356</programlisting> 357 </para> 358 359 <para> 360 Other clients and libraries might provide their own mechanisms, 361 via the shell or otherwise, that allow the user to alter session 362 settings without direct use of SQL commands. 363 </para> 364 </listitem> 365 </itemizedlist> 366 367 </sect2> 368 369 <sect2 id="config-includes"> 370 <title>Managing Configuration File Contents</title> 371 372 <para> 373 <productname>PostgreSQL</productname> provides several features for breaking 374 down complex <filename>postgresql.conf</filename> files into sub-files. 375 These features are especially useful when managing multiple servers 376 with related, but not identical, configurations. 377 </para> 378 379 <para> 380 <indexterm> 381 <primary><literal>include</literal></primary> 382 <secondary>in configuration file</secondary> 383 </indexterm> 384 In addition to individual parameter settings, 385 the <filename>postgresql.conf</filename> file can contain <firstterm>include 386 directives</firstterm>, which specify another file to read and process as if 387 it were inserted into the configuration file at this point. This 388 feature allows a configuration file to be divided into physically 389 separate parts. Include directives simply look like: 390<programlisting> 391include 'filename' 392</programlisting> 393 If the file name is not an absolute path, it is taken as relative to 394 the directory containing the referencing configuration file. 395 Inclusions can be nested. 396 </para> 397 398 <para> 399 <indexterm> 400 <primary><literal>include_if_exists</literal></primary> 401 <secondary>in configuration file</secondary> 402 </indexterm> 403 There is also an <literal>include_if_exists</literal> directive, which acts 404 the same as the <literal>include</literal> directive, except 405 when the referenced file does not exist or cannot be read. A regular 406 <literal>include</literal> will consider this an error condition, but 407 <literal>include_if_exists</literal> merely logs a message and continues 408 processing the referencing configuration file. 409 </para> 410 411 <para> 412 <indexterm> 413 <primary><literal>include_dir</literal></primary> 414 <secondary>in configuration file</secondary> 415 </indexterm> 416 The <filename>postgresql.conf</filename> file can also contain 417 <literal>include_dir</literal> directives, which specify an entire 418 directory of configuration files to include. These look like 419<programlisting> 420include_dir 'directory' 421</programlisting> 422 Non-absolute directory names are taken as relative to the directory 423 containing the referencing configuration file. Within the specified 424 directory, only non-directory files whose names end with the 425 suffix <literal>.conf</literal> will be included. File names that 426 start with the <literal>.</literal> character are also ignored, to 427 prevent mistakes since such files are hidden on some platforms. Multiple 428 files within an include directory are processed in file name order 429 (according to C locale rules, i.e., numbers before letters, and 430 uppercase letters before lowercase ones). 431 </para> 432 433 <para> 434 Include files or directories can be used to logically separate portions 435 of the database configuration, rather than having a single large 436 <filename>postgresql.conf</filename> file. Consider a company that has two 437 database servers, each with a different amount of memory. There are 438 likely elements of the configuration both will share, for things such 439 as logging. But memory-related parameters on the server will vary 440 between the two. And there might be server specific customizations, 441 too. One way to manage this situation is to break the custom 442 configuration changes for your site into three files. You could add 443 this to the end of your <filename>postgresql.conf</filename> file to include 444 them: 445<programlisting> 446include 'shared.conf' 447include 'memory.conf' 448include 'server.conf' 449</programlisting> 450 All systems would have the same <filename>shared.conf</filename>. Each 451 server with a particular amount of memory could share the 452 same <filename>memory.conf</filename>; you might have one for all servers 453 with 8GB of RAM, another for those having 16GB. And 454 finally <filename>server.conf</filename> could have truly server-specific 455 configuration information in it. 456 </para> 457 458 <para> 459 Another possibility is to create a configuration file directory and 460 put this information into files there. For example, a <filename>conf.d</filename> 461 directory could be referenced at the end of <filename>postgresql.conf</filename>: 462<programlisting> 463include_dir 'conf.d' 464</programlisting> 465 Then you could name the files in the <filename>conf.d</filename> directory 466 like this: 467<programlisting> 46800shared.conf 46901memory.conf 47002server.conf 471</programlisting> 472 This naming convention establishes a clear order in which these 473 files will be loaded. This is important because only the last 474 setting encountered for a particular parameter while the server is 475 reading configuration files will be used. In this example, 476 something set in <filename>conf.d/02server.conf</filename> would override a 477 value set in <filename>conf.d/01memory.conf</filename>. 478 </para> 479 480 <para> 481 You might instead use this approach to naming the files 482 descriptively: 483<programlisting> 48400shared.conf 48501memory-8GB.conf 48602server-foo.conf 487</programlisting> 488 This sort of arrangement gives a unique name for each configuration file 489 variation. This can help eliminate ambiguity when several servers have 490 their configurations all stored in one place, such as in a version 491 control repository. (Storing database configuration files under version 492 control is another good practice to consider.) 493 </para> 494 </sect2> 495 </sect1> 496 497 <sect1 id="runtime-config-file-locations"> 498 <title>File Locations</title> 499 500 <para> 501 In addition to the <filename>postgresql.conf</filename> file 502 already mentioned, <productname>PostgreSQL</productname> uses 503 two other manually-edited configuration files, which control 504 client authentication (their use is discussed in <xref 505 linkend="client-authentication"/>). By default, all three 506 configuration files are stored in the database cluster's data 507 directory. The parameters described in this section allow the 508 configuration files to be placed elsewhere. (Doing so can ease 509 administration. In particular it is often easier to ensure that 510 the configuration files are properly backed-up when they are 511 kept separate.) 512 </para> 513 514 <variablelist> 515 <varlistentry id="guc-data-directory" xreflabel="data_directory"> 516 <term><varname>data_directory</varname> (<type>string</type>) 517 <indexterm> 518 <primary><varname>data_directory</varname> configuration parameter</primary> 519 </indexterm> 520 </term> 521 <listitem> 522 <para> 523 Specifies the directory to use for data storage. 524 This parameter can only be set at server start. 525 </para> 526 </listitem> 527 </varlistentry> 528 529 <varlistentry id="guc-config-file" xreflabel="config_file"> 530 <term><varname>config_file</varname> (<type>string</type>) 531 <indexterm> 532 <primary><varname>config_file</varname> configuration parameter</primary> 533 </indexterm> 534 </term> 535 <listitem> 536 <para> 537 Specifies the main server configuration file 538 (customarily called <filename>postgresql.conf</filename>). 539 This parameter can only be set on the <command>postgres</command> command line. 540 </para> 541 </listitem> 542 </varlistentry> 543 544 <varlistentry id="guc-hba-file" xreflabel="hba_file"> 545 <term><varname>hba_file</varname> (<type>string</type>) 546 <indexterm> 547 <primary><varname>hba_file</varname> configuration parameter</primary> 548 </indexterm> 549 </term> 550 <listitem> 551 <para> 552 Specifies the configuration file for host-based authentication 553 (customarily called <filename>pg_hba.conf</filename>). 554 This parameter can only be set at server start. 555 </para> 556 </listitem> 557 </varlistentry> 558 559 <varlistentry id="guc-ident-file" xreflabel="ident_file"> 560 <term><varname>ident_file</varname> (<type>string</type>) 561 <indexterm> 562 <primary><varname>ident_file</varname> configuration parameter</primary> 563 </indexterm> 564 </term> 565 <listitem> 566 <para> 567 Specifies the configuration file for user name mapping 568 (customarily called <filename>pg_ident.conf</filename>). 569 This parameter can only be set at server start. 570 See also <xref linkend="auth-username-maps"/>. 571 </para> 572 </listitem> 573 </varlistentry> 574 575 <varlistentry id="guc-external-pid-file" xreflabel="external_pid_file"> 576 <term><varname>external_pid_file</varname> (<type>string</type>) 577 <indexterm> 578 <primary><varname>external_pid_file</varname> configuration parameter</primary> 579 </indexterm> 580 </term> 581 <listitem> 582 <para> 583 Specifies the name of an additional process-ID (PID) file that the 584 server should create for use by server administration programs. 585 This parameter can only be set at server start. 586 </para> 587 </listitem> 588 </varlistentry> 589 </variablelist> 590 591 <para> 592 In a default installation, none of the above parameters are set 593 explicitly. Instead, the 594 data directory is specified by the <option>-D</option> command-line 595 option or the <envar>PGDATA</envar> environment variable, and the 596 configuration files are all found within the data directory. 597 </para> 598 599 <para> 600 If you wish to keep the configuration files elsewhere than the 601 data directory, the <command>postgres</command> <option>-D</option> 602 command-line option or <envar>PGDATA</envar> environment variable 603 must point to the directory containing the configuration files, 604 and the <varname>data_directory</varname> parameter must be set in 605 <filename>postgresql.conf</filename> (or on the command line) to show 606 where the data directory is actually located. Notice that 607 <varname>data_directory</varname> overrides <option>-D</option> and 608 <envar>PGDATA</envar> for the location 609 of the data directory, but not for the location of the configuration 610 files. 611 </para> 612 613 <para> 614 If you wish, you can specify the configuration file names and locations 615 individually using the parameters <varname>config_file</varname>, 616 <varname>hba_file</varname> and/or <varname>ident_file</varname>. 617 <varname>config_file</varname> can only be specified on the 618 <command>postgres</command> command line, but the others can be 619 set within the main configuration file. If all three parameters plus 620 <varname>data_directory</varname> are explicitly set, then it is not necessary 621 to specify <option>-D</option> or <envar>PGDATA</envar>. 622 </para> 623 624 <para> 625 When setting any of these parameters, a relative path will be interpreted 626 with respect to the directory in which <command>postgres</command> 627 is started. 628 </para> 629 </sect1> 630 631 <sect1 id="runtime-config-connection"> 632 <title>Connections and Authentication</title> 633 634 <sect2 id="runtime-config-connection-settings"> 635 <title>Connection Settings</title> 636 637 <variablelist> 638 639 <varlistentry id="guc-listen-addresses" xreflabel="listen_addresses"> 640 <term><varname>listen_addresses</varname> (<type>string</type>) 641 <indexterm> 642 <primary><varname>listen_addresses</varname> configuration parameter</primary> 643 </indexterm> 644 </term> 645 <listitem> 646 <para> 647 Specifies the TCP/IP address(es) on which the server is 648 to listen for connections from client applications. 649 The value takes the form of a comma-separated list of host names 650 and/or numeric IP addresses. The special entry <literal>*</literal> 651 corresponds to all available IP interfaces. The entry 652 <literal>0.0.0.0</literal> allows listening for all IPv4 addresses and 653 <literal>::</literal> allows listening for all IPv6 addresses. 654 If the list is empty, the server does not listen on any IP interface 655 at all, in which case only Unix-domain sockets can be used to connect 656 to it. 657 The default value is <systemitem class="systemname">localhost</systemitem>, 658 which allows only local TCP/IP <quote>loopback</quote> connections to be 659 made. While client authentication (<xref 660 linkend="client-authentication"/>) allows fine-grained control 661 over who can access the server, <varname>listen_addresses</varname> 662 controls which interfaces accept connection attempts, which 663 can help prevent repeated malicious connection requests on 664 insecure network interfaces. This parameter can only be set 665 at server start. 666 </para> 667 </listitem> 668 </varlistentry> 669 670 <varlistentry id="guc-port" xreflabel="port"> 671 <term><varname>port</varname> (<type>integer</type>) 672 <indexterm> 673 <primary><varname>port</varname> configuration parameter</primary> 674 </indexterm> 675 </term> 676 <listitem> 677 <para> 678 The TCP port the server listens on; 5432 by default. Note that the 679 same port number is used for all IP addresses the server listens on. 680 This parameter can only be set at server start. 681 </para> 682 </listitem> 683 </varlistentry> 684 685 <varlistentry id="guc-max-connections" xreflabel="max_connections"> 686 <term><varname>max_connections</varname> (<type>integer</type>) 687 <indexterm> 688 <primary><varname>max_connections</varname> configuration parameter</primary> 689 </indexterm> 690 </term> 691 <listitem> 692 <para> 693 Determines the maximum number of concurrent connections to the 694 database server. The default is typically 100 connections, but 695 might be less if your kernel settings will not support it (as 696 determined during <application>initdb</application>). This parameter can 697 only be set at server start. 698 </para> 699 700 <para> 701 When running a standby server, you must set this parameter to the 702 same or higher value than on the master server. Otherwise, queries 703 will not be allowed in the standby server. 704 </para> 705 </listitem> 706 </varlistentry> 707 708 <varlistentry id="guc-superuser-reserved-connections" 709 xreflabel="superuser_reserved_connections"> 710 <term><varname>superuser_reserved_connections</varname> 711 (<type>integer</type>) 712 <indexterm> 713 <primary><varname>superuser_reserved_connections</varname> configuration parameter</primary> 714 </indexterm> 715 </term> 716 <listitem> 717 <para> 718 Determines the number of connection <quote>slots</quote> that 719 are reserved for connections by <productname>PostgreSQL</productname> 720 superusers. At most <xref linkend="guc-max-connections"/> 721 connections can ever be active simultaneously. Whenever the 722 number of active concurrent connections is at least 723 <varname>max_connections</varname> minus 724 <varname>superuser_reserved_connections</varname>, new 725 connections will be accepted only for superusers, and no 726 new replication connections will be accepted. 727 </para> 728 729 <para> 730 The default value is three connections. The value must be less 731 than <varname>max_connections</varname>. 732 This parameter can only be set at server start. 733 </para> 734 </listitem> 735 </varlistentry> 736 737 <varlistentry id="guc-unix-socket-directories" xreflabel="unix_socket_directories"> 738 <term><varname>unix_socket_directories</varname> (<type>string</type>) 739 <indexterm> 740 <primary><varname>unix_socket_directories</varname> configuration parameter</primary> 741 </indexterm> 742 </term> 743 <listitem> 744 <para> 745 Specifies the directory of the Unix-domain socket(s) on which the 746 server is to listen for connections from client applications. 747 Multiple sockets can be created by listing multiple directories 748 separated by commas. Whitespace between entries is 749 ignored; surround a directory name with double quotes if you need 750 to include whitespace or commas in the name. 751 An empty value 752 specifies not listening on any Unix-domain sockets, in which case 753 only TCP/IP sockets can be used to connect to the server. 754 The default value is normally 755 <filename>/tmp</filename>, but that can be changed at build time. 756 On Windows, the default is empty, which means no Unix-domain socket is 757 created by default. 758 This parameter can only be set at server start. 759 </para> 760 761 <para> 762 In addition to the socket file itself, which is named 763 <literal>.s.PGSQL.<replaceable>nnnn</replaceable></literal> where 764 <replaceable>nnnn</replaceable> is the server's port number, an ordinary file 765 named <literal>.s.PGSQL.<replaceable>nnnn</replaceable>.lock</literal> will be 766 created in each of the <varname>unix_socket_directories</varname> directories. 767 Neither file should ever be removed manually. 768 </para> 769 </listitem> 770 </varlistentry> 771 772 <varlistentry id="guc-unix-socket-group" xreflabel="unix_socket_group"> 773 <term><varname>unix_socket_group</varname> (<type>string</type>) 774 <indexterm> 775 <primary><varname>unix_socket_group</varname> configuration parameter</primary> 776 </indexterm> 777 </term> 778 <listitem> 779 <para> 780 Sets the owning group of the Unix-domain socket(s). (The owning 781 user of the sockets is always the user that starts the 782 server.) In combination with the parameter 783 <varname>unix_socket_permissions</varname> this can be used as 784 an additional access control mechanism for Unix-domain connections. 785 By default this is the empty string, which uses the default 786 group of the server user. This parameter can only be set at 787 server start. 788 </para> 789 790 <para> 791 This parameter is not supported on Windows. Any setting will be 792 ignored. 793 </para> 794 </listitem> 795 </varlistentry> 796 797 <varlistentry id="guc-unix-socket-permissions" xreflabel="unix_socket_permissions"> 798 <term><varname>unix_socket_permissions</varname> (<type>integer</type>) 799 <indexterm> 800 <primary><varname>unix_socket_permissions</varname> configuration parameter</primary> 801 </indexterm> 802 </term> 803 <listitem> 804 <para> 805 Sets the access permissions of the Unix-domain socket(s). Unix-domain 806 sockets use the usual Unix file system permission set. 807 The parameter value is expected to be a numeric mode 808 specified in the format accepted by the 809 <function>chmod</function> and <function>umask</function> 810 system calls. (To use the customary octal format the number 811 must start with a <literal>0</literal> (zero).) 812 </para> 813 814 <para> 815 The default permissions are <literal>0777</literal>, meaning 816 anyone can connect. Reasonable alternatives are 817 <literal>0770</literal> (only user and group, see also 818 <varname>unix_socket_group</varname>) and <literal>0700</literal> 819 (only user). (Note that for a Unix-domain socket, only write 820 permission matters, so there is no point in setting or revoking 821 read or execute permissions.) 822 </para> 823 824 <para> 825 This access control mechanism is independent of the one 826 described in <xref linkend="client-authentication"/>. 827 </para> 828 829 <para> 830 This parameter can only be set at server start. 831 </para> 832 833 <para> 834 This parameter is irrelevant on systems, notably Solaris as of Solaris 835 10, that ignore socket permissions entirely. There, one can achieve a 836 similar effect by pointing <varname>unix_socket_directories</varname> to a 837 directory having search permission limited to the desired audience. 838 </para> 839 </listitem> 840 </varlistentry> 841 842 <varlistentry id="guc-bonjour" xreflabel="bonjour"> 843 <term><varname>bonjour</varname> (<type>boolean</type>) 844 <indexterm> 845 <primary><varname>bonjour</varname> configuration parameter</primary> 846 </indexterm> 847 </term> 848 <listitem> 849 <para> 850 Enables advertising the server's existence via 851 <productname>Bonjour</productname>. The default is off. 852 This parameter can only be set at server start. 853 </para> 854 </listitem> 855 </varlistentry> 856 857 <varlistentry id="guc-bonjour-name" xreflabel="bonjour_name"> 858 <term><varname>bonjour_name</varname> (<type>string</type>) 859 <indexterm> 860 <primary><varname>bonjour_name</varname> configuration parameter</primary> 861 </indexterm> 862 </term> 863 <listitem> 864 <para> 865 Specifies the <productname>Bonjour</productname> service 866 name. The computer name is used if this parameter is set to the 867 empty string <literal>''</literal> (which is the default). This parameter is 868 ignored if the server was not compiled with 869 <productname>Bonjour</productname> support. 870 This parameter can only be set at server start. 871 </para> 872 </listitem> 873 </varlistentry> 874 875 <varlistentry id="guc-tcp-keepalives-idle" xreflabel="tcp_keepalives_idle"> 876 <term><varname>tcp_keepalives_idle</varname> (<type>integer</type>) 877 <indexterm> 878 <primary><varname>tcp_keepalives_idle</varname> configuration parameter</primary> 879 </indexterm> 880 </term> 881 <listitem> 882 <para> 883 Specifies the amount of time with no network activity after which 884 the operating system should send a TCP keepalive message to the client. 885 If this value is specified without units, it is taken as seconds. 886 A value of 0 (the default) selects the operating system's default. 887 This parameter is supported only on systems that support 888 <symbol>TCP_KEEPIDLE</symbol> or an equivalent socket option, and on 889 Windows; on other systems, it must be zero. 890 In sessions connected via a Unix-domain socket, this parameter is 891 ignored and always reads as zero. 892 </para> 893 <note> 894 <para> 895 On Windows, setting a value of 0 will set this parameter to 2 hours, 896 since Windows does not provide a way to read the system default value. 897 </para> 898 </note> 899 </listitem> 900 </varlistentry> 901 902 <varlistentry id="guc-tcp-keepalives-interval" xreflabel="tcp_keepalives_interval"> 903 <term><varname>tcp_keepalives_interval</varname> (<type>integer</type>) 904 <indexterm> 905 <primary><varname>tcp_keepalives_interval</varname> configuration parameter</primary> 906 </indexterm> 907 </term> 908 <listitem> 909 <para> 910 Specifies the amount of time after which a TCP keepalive message 911 that has not been acknowledged by the client should be retransmitted. 912 If this value is specified without units, it is taken as seconds. 913 A value of 0 (the default) selects the operating system's default. 914 This parameter is supported only on systems that support 915 <symbol>TCP_KEEPINTVL</symbol> or an equivalent socket option, and on 916 Windows; on other systems, it must be zero. 917 In sessions connected via a Unix-domain socket, this parameter is 918 ignored and always reads as zero. 919 </para> 920 <note> 921 <para> 922 On Windows, setting a value of 0 will set this parameter to 1 second, 923 since Windows does not provide a way to read the system default value. 924 </para> 925 </note> 926 </listitem> 927 </varlistentry> 928 929 <varlistentry id="guc-tcp-keepalives-count" xreflabel="tcp_keepalives_count"> 930 <term><varname>tcp_keepalives_count</varname> (<type>integer</type>) 931 <indexterm> 932 <primary><varname>tcp_keepalives_count</varname> configuration parameter</primary> 933 </indexterm> 934 </term> 935 <listitem> 936 <para> 937 Specifies the number of TCP keepalive messages that can be lost before 938 the server's connection to the client is considered dead. 939 A value of 0 (the default) selects the operating system's default. 940 This parameter is supported only on systems that support 941 <symbol>TCP_KEEPCNT</symbol> or an equivalent socket option; 942 on other systems, it must be zero. 943 In sessions connected via a Unix-domain socket, this parameter is 944 ignored and always reads as zero. 945 </para> 946 <note> 947 <para> 948 This parameter is not supported on Windows, and must be zero. 949 </para> 950 </note> 951 </listitem> 952 </varlistentry> 953 954 <varlistentry id="guc-tcp-user-timeout" xreflabel="tcp_user_timeout"> 955 <term><varname>tcp_user_timeout</varname> (<type>integer</type>) 956 <indexterm> 957 <primary><varname>tcp_user_timeout</varname> configuration parameter</primary> 958 </indexterm> 959 </term> 960 <listitem> 961 <para> 962 Specifies the amount of time that transmitted data may 963 remain unacknowledged before the TCP connection is forcibly closed. 964 If this value is specified without units, it is taken as milliseconds. 965 A value of 0 (the default) selects the operating system's default. 966 This parameter is supported only on systems that support 967 <symbol>TCP_USER_TIMEOUT</symbol>; on other systems, it must be zero. 968 In sessions connected via a Unix-domain socket, this parameter is 969 ignored and always reads as zero. 970 </para> 971 <note> 972 <para> 973 This parameter is not supported on Windows, and must be zero. 974 </para> 975 </note> 976 </listitem> 977 </varlistentry> 978 979 </variablelist> 980 </sect2> 981 982 <sect2 id="runtime-config-connection-authentication"> 983 <title>Authentication</title> 984 985 <variablelist> 986 <varlistentry id="guc-authentication-timeout" xreflabel="authentication_timeout"> 987 <term><varname>authentication_timeout</varname> (<type>integer</type>) 988 <indexterm><primary>timeout</primary><secondary>client authentication</secondary></indexterm> 989 <indexterm><primary>client authentication</primary><secondary>timeout during</secondary></indexterm> 990 <indexterm> 991 <primary><varname>authentication_timeout</varname> configuration parameter</primary> 992 </indexterm> 993 </term> 994 995 <listitem> 996 <para> 997 Maximum amount of time allowed to complete client authentication. If a 998 would-be client has not completed the authentication protocol in 999 this much time, the server closes the connection. This prevents 1000 hung clients from occupying a connection indefinitely. 1001 If this value is specified without units, it is taken as seconds. 1002 The default is one minute (<literal>1m</literal>). 1003 This parameter can only be set in the <filename>postgresql.conf</filename> 1004 file or on the server command line. 1005 </para> 1006 </listitem> 1007 </varlistentry> 1008 1009 <varlistentry id="guc-password-encryption" xreflabel="password_encryption"> 1010 <term><varname>password_encryption</varname> (<type>enum</type>) 1011 <indexterm> 1012 <primary><varname>password_encryption</varname> configuration parameter</primary> 1013 </indexterm> 1014 </term> 1015 <listitem> 1016 <para> 1017 When a password is specified in <xref linkend="sql-createrole"/> or 1018 <xref linkend="sql-alterrole"/>, this parameter determines the algorithm 1019 to use to encrypt the password. The default value is <literal>md5</literal>, 1020 which stores the password as an MD5 hash (<literal>on</literal> is also 1021 accepted, as alias for <literal>md5</literal>). Setting this parameter to 1022 <literal>scram-sha-256</literal> will encrypt the password with SCRAM-SHA-256. 1023 </para> 1024 <para> 1025 Note that older clients might lack support for the SCRAM authentication 1026 mechanism, and hence not work with passwords encrypted with 1027 SCRAM-SHA-256. See <xref linkend="auth-password"/> for more details. 1028 </para> 1029 </listitem> 1030 </varlistentry> 1031 1032 <varlistentry id="guc-krb-server-keyfile" xreflabel="krb_server_keyfile"> 1033 <term><varname>krb_server_keyfile</varname> (<type>string</type>) 1034 <indexterm> 1035 <primary><varname>krb_server_keyfile</varname> configuration parameter</primary> 1036 </indexterm> 1037 </term> 1038 <listitem> 1039 <para> 1040 Sets the location of the server's Kerberos key file. The default is 1041 <filename>FILE:/usr/local/pgsql/etc/krb5.keytab</filename> 1042 (where the directory part is whatever was specified 1043 as <varname>sysconfdir</varname> at build time; use 1044 <literal>pg_config --sysconfdir</literal> to determine that). 1045 If this parameter is set to an empty string, it is ignored and a 1046 system-dependent default is used. 1047 This parameter can only be set in the 1048 <filename>postgresql.conf</filename> file or on the server command line. 1049 See <xref linkend="gssapi-auth"/> for more information. 1050 </para> 1051 </listitem> 1052 </varlistentry> 1053 1054 <varlistentry id="guc-krb-caseins-users" xreflabel="krb_caseins_users"> 1055 <term><varname>krb_caseins_users</varname> (<type>boolean</type>) 1056 <indexterm> 1057 <primary><varname>krb_caseins_users</varname> configuration parameter</primary> 1058 </indexterm> 1059 </term> 1060 <listitem> 1061 <para> 1062 Sets whether GSSAPI user names should be treated 1063 case-insensitively. 1064 The default is <literal>off</literal> (case sensitive). This parameter can only be 1065 set in the <filename>postgresql.conf</filename> file or on the server command line. 1066 </para> 1067 </listitem> 1068 </varlistentry> 1069 1070 <varlistentry id="guc-db-user-namespace" xreflabel="db_user_namespace"> 1071 <term><varname>db_user_namespace</varname> (<type>boolean</type>) 1072 <indexterm> 1073 <primary><varname>db_user_namespace</varname> configuration parameter</primary> 1074 </indexterm> 1075 </term> 1076 <listitem> 1077 <para> 1078 This parameter enables per-database user names. It is off by default. 1079 This parameter can only be set in the <filename>postgresql.conf</filename> 1080 file or on the server command line. 1081 </para> 1082 1083 <para> 1084 If this is on, you should create users as <replaceable>username@dbname</replaceable>. 1085 When <replaceable>username</replaceable> is passed by a connecting client, 1086 <literal>@</literal> and the database name are appended to the user 1087 name and that database-specific user name is looked up by the 1088 server. Note that when you create users with names containing 1089 <literal>@</literal> within the SQL environment, you will need to 1090 quote the user name. 1091 </para> 1092 1093 <para> 1094 With this parameter enabled, you can still create ordinary global 1095 users. Simply append <literal>@</literal> when specifying the user 1096 name in the client, e.g., <literal>joe@</literal>. The <literal>@</literal> 1097 will be stripped off before the user name is looked up by the 1098 server. 1099 </para> 1100 1101 <para> 1102 <varname>db_user_namespace</varname> causes the client's and 1103 server's user name representation to differ. 1104 Authentication checks are always done with the server's user name 1105 so authentication methods must be configured for the 1106 server's user name, not the client's. Because 1107 <literal>md5</literal> uses the user name as salt on both the 1108 client and server, <literal>md5</literal> cannot be used with 1109 <varname>db_user_namespace</varname>. 1110 </para> 1111 1112 <note> 1113 <para> 1114 This feature is intended as a temporary measure until a 1115 complete solution is found. At that time, this option will 1116 be removed. 1117 </para> 1118 </note> 1119 </listitem> 1120 </varlistentry> 1121 </variablelist> 1122 </sect2> 1123 1124 <sect2 id="runtime-config-connection-ssl"> 1125 <title>SSL</title> 1126 1127 <para> 1128 See <xref linkend="ssl-tcp"/> for more information about setting up SSL. 1129 </para> 1130 1131 <variablelist> 1132 <varlistentry id="guc-ssl" xreflabel="ssl"> 1133 <term><varname>ssl</varname> (<type>boolean</type>) 1134 <indexterm> 1135 <primary><varname>ssl</varname> configuration parameter</primary> 1136 </indexterm> 1137 </term> 1138 <listitem> 1139 <para> 1140 Enables <acronym>SSL</acronym> connections. 1141 This parameter can only be set in the <filename>postgresql.conf</filename> 1142 file or on the server command line. 1143 The default is <literal>off</literal>. 1144 </para> 1145 </listitem> 1146 </varlistentry> 1147 1148 <varlistentry id="guc-ssl-ca-file" xreflabel="ssl_ca_file"> 1149 <term><varname>ssl_ca_file</varname> (<type>string</type>) 1150 <indexterm> 1151 <primary><varname>ssl_ca_file</varname> configuration parameter</primary> 1152 </indexterm> 1153 </term> 1154 <listitem> 1155 <para> 1156 Specifies the name of the file containing the SSL server certificate 1157 authority (CA). 1158 Relative paths are relative to the data directory. 1159 This parameter can only be set in the <filename>postgresql.conf</filename> 1160 file or on the server command line. 1161 The default is empty, meaning no CA file is loaded, 1162 and client certificate verification is not performed. 1163 </para> 1164 </listitem> 1165 </varlistentry> 1166 1167 <varlistentry id="guc-ssl-cert-file" xreflabel="ssl_cert_file"> 1168 <term><varname>ssl_cert_file</varname> (<type>string</type>) 1169 <indexterm> 1170 <primary><varname>ssl_cert_file</varname> configuration parameter</primary> 1171 </indexterm> 1172 </term> 1173 <listitem> 1174 <para> 1175 Specifies the name of the file containing the SSL server certificate. 1176 Relative paths are relative to the data directory. 1177 This parameter can only be set in the <filename>postgresql.conf</filename> 1178 file or on the server command line. 1179 The default is <filename>server.crt</filename>. 1180 </para> 1181 </listitem> 1182 </varlistentry> 1183 1184 <varlistentry id="guc-ssl-crl-file" xreflabel="ssl_crl_file"> 1185 <term><varname>ssl_crl_file</varname> (<type>string</type>) 1186 <indexterm> 1187 <primary><varname>ssl_crl_file</varname> configuration parameter</primary> 1188 </indexterm> 1189 </term> 1190 <listitem> 1191 <para> 1192 Specifies the name of the file containing the SSL server certificate 1193 revocation list (CRL). 1194 Relative paths are relative to the data directory. 1195 This parameter can only be set in the <filename>postgresql.conf</filename> 1196 file or on the server command line. 1197 The default is empty, meaning no CRL file is loaded. 1198 </para> 1199 </listitem> 1200 </varlistentry> 1201 1202 <varlistentry id="guc-ssl-key-file" xreflabel="ssl_key_file"> 1203 <term><varname>ssl_key_file</varname> (<type>string</type>) 1204 <indexterm> 1205 <primary><varname>ssl_key_file</varname> configuration parameter</primary> 1206 </indexterm> 1207 </term> 1208 <listitem> 1209 <para> 1210 Specifies the name of the file containing the SSL server private key. 1211 Relative paths are relative to the data directory. 1212 This parameter can only be set in the <filename>postgresql.conf</filename> 1213 file or on the server command line. 1214 The default is <filename>server.key</filename>. 1215 </para> 1216 </listitem> 1217 </varlistentry> 1218 1219 <varlistentry id="guc-ssl-ciphers" xreflabel="ssl_ciphers"> 1220 <term><varname>ssl_ciphers</varname> (<type>string</type>) 1221 <indexterm> 1222 <primary><varname>ssl_ciphers</varname> configuration parameter</primary> 1223 </indexterm> 1224 </term> 1225 <listitem> 1226 <para> 1227 Specifies a list of <acronym>SSL</acronym> cipher suites that are 1228 allowed to be used by SSL connections. See the 1229 <citerefentry><refentrytitle>ciphers</refentrytitle></citerefentry> 1230 manual page in the <application>OpenSSL</application> package for the 1231 syntax of this setting and a list of supported values. Only 1232 connections using TLS version 1.2 and lower are affected. There is 1233 currently no setting that controls the cipher choices used by TLS 1234 version 1.3 connections. The default value is 1235 <literal>HIGH:MEDIUM:+3DES:!aNULL</literal>. The default is usually a 1236 reasonable choice unless you have specific security requirements. 1237 </para> 1238 1239 <para> 1240 This parameter can only be set in the 1241 <filename>postgresql.conf</filename> file or on the server command 1242 line. 1243 </para> 1244 1245 <para> 1246 Explanation of the default value: 1247 <variablelist> 1248 <varlistentry> 1249 <term><literal>HIGH</literal></term> 1250 <listitem> 1251 <para> 1252 Cipher suites that use ciphers from <literal>HIGH</literal> group (e.g., 1253 AES, Camellia, 3DES) 1254 </para> 1255 </listitem> 1256 </varlistentry> 1257 1258 <varlistentry> 1259 <term><literal>MEDIUM</literal></term> 1260 <listitem> 1261 <para> 1262 Cipher suites that use ciphers from <literal>MEDIUM</literal> group 1263 (e.g., RC4, SEED) 1264 </para> 1265 </listitem> 1266 </varlistentry> 1267 1268 <varlistentry> 1269 <term><literal>+3DES</literal></term> 1270 <listitem> 1271 <para> 1272 The OpenSSL default order for <literal>HIGH</literal> is problematic 1273 because it orders 3DES higher than AES128. This is wrong because 1274 3DES offers less security than AES128, and it is also much 1275 slower. <literal>+3DES</literal> reorders it after all other 1276 <literal>HIGH</literal> and <literal>MEDIUM</literal> ciphers. 1277 </para> 1278 </listitem> 1279 </varlistentry> 1280 1281 <varlistentry> 1282 <term><literal>!aNULL</literal></term> 1283 <listitem> 1284 <para> 1285 Disables anonymous cipher suites that do no authentication. Such 1286 cipher suites are vulnerable to man-in-the-middle attacks and 1287 therefore should not be used. 1288 </para> 1289 </listitem> 1290 </varlistentry> 1291 </variablelist> 1292 </para> 1293 1294 <para> 1295 Available cipher suite details will vary across OpenSSL versions. Use 1296 the command 1297 <literal>openssl ciphers -v 'HIGH:MEDIUM:+3DES:!aNULL'</literal> to 1298 see actual details for the currently installed <application>OpenSSL</application> 1299 version. Note that this list is filtered at run time based on the 1300 server key type. 1301 </para> 1302 </listitem> 1303 </varlistentry> 1304 1305 <varlistentry id="guc-ssl-prefer-server-ciphers" xreflabel="ssl_prefer_server_ciphers"> 1306 <term><varname>ssl_prefer_server_ciphers</varname> (<type>boolean</type>) 1307 <indexterm> 1308 <primary><varname>ssl_prefer_server_ciphers</varname> configuration parameter</primary> 1309 </indexterm> 1310 </term> 1311 <listitem> 1312 <para> 1313 Specifies whether to use the server's SSL cipher preferences, rather 1314 than the client's. 1315 This parameter can only be set in the <filename>postgresql.conf</filename> 1316 file or on the server command line. 1317 The default is <literal>on</literal>. 1318 </para> 1319 1320 <para> 1321 Older PostgreSQL versions do not have this setting and always use the 1322 client's preferences. This setting is mainly for backward 1323 compatibility with those versions. Using the server's preferences is 1324 usually better because it is more likely that the server is appropriately 1325 configured. 1326 </para> 1327 </listitem> 1328 </varlistentry> 1329 1330 <varlistentry id="guc-ssl-ecdh-curve" xreflabel="ssl_ecdh_curve"> 1331 <term><varname>ssl_ecdh_curve</varname> (<type>string</type>) 1332 <indexterm> 1333 <primary><varname>ssl_ecdh_curve</varname> configuration parameter</primary> 1334 </indexterm> 1335 </term> 1336 <listitem> 1337 <para> 1338 Specifies the name of the curve to use in <acronym>ECDH</acronym> key 1339 exchange. It needs to be supported by all clients that connect. 1340 It does not need to be the same curve used by the server's Elliptic 1341 Curve key. 1342 This parameter can only be set in the <filename>postgresql.conf</filename> 1343 file or on the server command line. 1344 The default is <literal>prime256v1</literal>. 1345 </para> 1346 1347 <para> 1348 OpenSSL names for the most common curves are: 1349 <literal>prime256v1</literal> (NIST P-256), 1350 <literal>secp384r1</literal> (NIST P-384), 1351 <literal>secp521r1</literal> (NIST P-521). 1352 The full list of available curves can be shown with the command 1353 <command>openssl ecparam -list_curves</command>. Not all of them 1354 are usable in <acronym>TLS</acronym> though. 1355 </para> 1356 </listitem> 1357 </varlistentry> 1358 1359 <varlistentry id="guc-ssl-min-protocol-version" xreflabel="ssl_min_protocol_version"> 1360 <term><varname>ssl_min_protocol_version</varname> (<type>enum</type>) 1361 <indexterm> 1362 <primary><varname>ssl_min_protocol_version</varname> configuration parameter</primary> 1363 </indexterm> 1364 </term> 1365 <listitem> 1366 <para> 1367 Sets the minimum SSL/TLS protocol version to use. Valid values are 1368 currently: <literal>TLSv1</literal>, <literal>TLSv1.1</literal>, 1369 <literal>TLSv1.2</literal>, <literal>TLSv1.3</literal>. Older 1370 versions of the <productname>OpenSSL</productname> library do not 1371 support all values; an error will be raised if an unsupported setting 1372 is chosen. Protocol versions before TLS 1.0, namely SSL version 2 and 1373 3, are always disabled. 1374 </para> 1375 1376 <para> 1377 The default is <literal>TLSv1.2</literal>, which satisfies industry 1378 best practices as of this writing. 1379 </para> 1380 1381 <para> 1382 This parameter can only be set in the <filename>postgresql.conf</filename> 1383 file or on the server command line. 1384 </para> 1385 </listitem> 1386 </varlistentry> 1387 1388 <varlistentry id="guc-ssl-max-protocol-version" xreflabel="ssl_max_protocol_version"> 1389 <term><varname>ssl_max_protocol_version</varname> (<type>enum</type>) 1390 <indexterm> 1391 <primary><varname>ssl_max_protocol_version</varname> configuration parameter</primary> 1392 </indexterm> 1393 </term> 1394 <listitem> 1395 <para> 1396 Sets the maximum SSL/TLS protocol version to use. Valid values are as 1397 for <xref linkend="guc-ssl-min-protocol-version"/>, with addition of 1398 an empty string, which allows any protocol version. The default is to 1399 allow any version. Setting the maximum protocol version is mainly 1400 useful for testing or if some component has issues working with a 1401 newer protocol. 1402 </para> 1403 1404 <para> 1405 This parameter can only be set in the <filename>postgresql.conf</filename> 1406 file or on the server command line. 1407 </para> 1408 </listitem> 1409 </varlistentry> 1410 1411 <varlistentry id="guc-ssl-dh-params-file" xreflabel="ssl_dh_params_file"> 1412 <term><varname>ssl_dh_params_file</varname> (<type>string</type>) 1413 <indexterm> 1414 <primary><varname>ssl_dh_params_file</varname> configuration parameter</primary> 1415 </indexterm> 1416 </term> 1417 <listitem> 1418 <para> 1419 Specifies the name of the file containing Diffie-Hellman parameters 1420 used for so-called ephemeral DH family of SSL ciphers. The default is 1421 empty, in which case compiled-in default DH parameters used. Using 1422 custom DH parameters reduces the exposure if an attacker manages to 1423 crack the well-known compiled-in DH parameters. You can create your own 1424 DH parameters file with the command 1425 <command>openssl dhparam -out dhparams.pem 2048</command>. 1426 </para> 1427 1428 <para> 1429 This parameter can only be set in the <filename>postgresql.conf</filename> 1430 file or on the server command line. 1431 </para> 1432 </listitem> 1433 </varlistentry> 1434 1435 <varlistentry id="guc-ssl-passphrase-command" xreflabel="ssl_passphrase_command"> 1436 <term><varname>ssl_passphrase_command</varname> (<type>string</type>) 1437 <indexterm> 1438 <primary><varname>ssl_passphrase_command</varname> configuration parameter</primary> 1439 </indexterm> 1440 </term> 1441 <listitem> 1442 <para> 1443 Sets an external command to be invoked when a passphrase for 1444 decrypting an SSL file such as a private key needs to be obtained. By 1445 default, this parameter is empty, which means the built-in prompting 1446 mechanism is used. 1447 </para> 1448 <para> 1449 The command must print the passphrase to the standard output and exit 1450 with code 0. In the parameter value, <literal>%p</literal> is 1451 replaced by a prompt string. (Write <literal>%%</literal> for a 1452 literal <literal>%</literal>.) Note that the prompt string will 1453 probably contain whitespace, so be sure to quote adequately. A single 1454 newline is stripped from the end of the output if present. 1455 </para> 1456 <para> 1457 The command does not actually have to prompt the user for a 1458 passphrase. It can read it from a file, obtain it from a keychain 1459 facility, or similar. It is up to the user to make sure the chosen 1460 mechanism is adequately secure. 1461 </para> 1462 <para> 1463 This parameter can only be set in the <filename>postgresql.conf</filename> 1464 file or on the server command line. 1465 </para> 1466 </listitem> 1467 </varlistentry> 1468 1469 <varlistentry id="guc-ssl-passphrase-command-supports-reload" xreflabel="ssl_passphrase_command_supports_reload"> 1470 <term><varname>ssl_passphrase_command_supports_reload</varname> (<type>boolean</type>) 1471 <indexterm> 1472 <primary><varname>ssl_passphrase_command_supports_reload</varname> configuration parameter</primary> 1473 </indexterm> 1474 </term> 1475 <listitem> 1476 <para> 1477 This parameter determines whether the passphrase command set by 1478 <varname>ssl_passphrase_command</varname> will also be called during a 1479 configuration reload if a key file needs a passphrase. If this 1480 parameter is off (the default), then 1481 <varname>ssl_passphrase_command</varname> will be ignored during a 1482 reload and the SSL configuration will not be reloaded if a passphrase 1483 is needed. That setting is appropriate for a command that requires a 1484 TTY for prompting, which might not be available when the server is 1485 running. Setting this parameter to on might be appropriate if the 1486 passphrase is obtained from a file, for example. 1487 </para> 1488 <para> 1489 This parameter can only be set in the <filename>postgresql.conf</filename> 1490 file or on the server command line. 1491 </para> 1492 </listitem> 1493 </varlistentry> 1494 </variablelist> 1495 </sect2> 1496 </sect1> 1497 1498 <sect1 id="runtime-config-resource"> 1499 <title>Resource Consumption</title> 1500 1501 <sect2 id="runtime-config-resource-memory"> 1502 <title>Memory</title> 1503 1504 <variablelist> 1505 <varlistentry id="guc-shared-buffers" xreflabel="shared_buffers"> 1506 <term><varname>shared_buffers</varname> (<type>integer</type>) 1507 <indexterm> 1508 <primary><varname>shared_buffers</varname> configuration parameter</primary> 1509 </indexterm> 1510 </term> 1511 <listitem> 1512 <para> 1513 Sets the amount of memory the database server uses for shared 1514 memory buffers. The default is typically 128 megabytes 1515 (<literal>128MB</literal>), but might be less if your kernel settings will 1516 not support it (as determined during <application>initdb</application>). 1517 This setting must be at least 128 kilobytes. However, 1518 settings significantly higher than the minimum are usually needed 1519 for good performance. 1520 If this value is specified without units, it is taken as blocks, 1521 that is <symbol>BLCKSZ</symbol> bytes, typically 8kB. 1522 (Non-default values of <symbol>BLCKSZ</symbol> change the minimum 1523 value.) 1524 This parameter can only be set at server start. 1525 </para> 1526 1527 <para> 1528 If you have a dedicated database server with 1GB or more of RAM, a 1529 reasonable starting value for <varname>shared_buffers</varname> is 25% 1530 of the memory in your system. There are some workloads where even 1531 larger settings for <varname>shared_buffers</varname> are effective, but 1532 because <productname>PostgreSQL</productname> also relies on the 1533 operating system cache, it is unlikely that an allocation of more than 1534 40% of RAM to <varname>shared_buffers</varname> will work better than a 1535 smaller amount. Larger settings for <varname>shared_buffers</varname> 1536 usually require a corresponding increase in 1537 <varname>max_wal_size</varname>, in order to spread out the 1538 process of writing large quantities of new or changed data over a 1539 longer period of time. 1540 </para> 1541 1542 <para> 1543 On systems with less than 1GB of RAM, a smaller percentage of RAM is 1544 appropriate, so as to leave adequate space for the operating system. 1545 </para> 1546 1547 </listitem> 1548 </varlistentry> 1549 1550 <varlistentry id="guc-huge-pages" xreflabel="huge_pages"> 1551 <term><varname>huge_pages</varname> (<type>enum</type>) 1552 <indexterm> 1553 <primary><varname>huge_pages</varname> configuration parameter</primary> 1554 </indexterm> 1555 </term> 1556 <listitem> 1557 <para> 1558 Controls whether huge pages are requested for the main shared memory 1559 area. Valid values are <literal>try</literal> (the default), 1560 <literal>on</literal>, and <literal>off</literal>. With 1561 <varname>huge_pages</varname> set to <literal>try</literal>, the 1562 server will try to request huge pages, but fall back to the default if 1563 that fails. With <literal>on</literal>, failure to request huge pages 1564 will prevent the server from starting up. With <literal>off</literal>, 1565 huge pages will not be requested. 1566 </para> 1567 1568 <para> 1569 At present, this setting is supported only on Linux and Windows. The 1570 setting is ignored on other systems when set to 1571 <literal>try</literal>. On Linux, it is only supported when 1572 <varname>shared_memory_type</varname> is set to <literal>mmap</literal> 1573 (the default). 1574 </para> 1575 1576 <para> 1577 The use of huge pages results in smaller page tables and less CPU time 1578 spent on memory management, increasing performance. For more details about 1579 using huge pages on Linux, see <xref linkend="linux-huge-pages"/>. 1580 </para> 1581 1582 <para> 1583 Huge pages are known as large pages on Windows. To use them, you need to 1584 assign the user right Lock Pages in Memory to the Windows user account 1585 that runs <productname>PostgreSQL</productname>. 1586 You can use Windows Group Policy tool (gpedit.msc) to assign the user right 1587 Lock Pages in Memory. 1588 To start the database server on the command prompt as a standalone process, 1589 not as a Windows service, the command prompt must be run as an administrator or 1590 User Access Control (UAC) must be disabled. When the UAC is enabled, the normal 1591 command prompt revokes the user right Lock Pages in Memory when started. 1592 </para> 1593 1594 <para> 1595 Note that this setting only affects the main shared memory area. 1596 Operating systems such as Linux, FreeBSD, and Illumos can also use 1597 huge pages (also known as <quote>super</quote> pages or 1598 <quote>large</quote> pages) automatically for normal memory 1599 allocation, without an explicit request from 1600 <productname>PostgreSQL</productname>. On Linux, this is called 1601 <quote>transparent huge pages</quote><indexterm><primary>transparent 1602 huge pages</primary></indexterm> (THP). That feature has been known to 1603 cause performance degradation with 1604 <productname>PostgreSQL</productname> for some users on some Linux 1605 versions, so its use is currently discouraged (unlike explicit use of 1606 <varname>huge_pages</varname>). 1607 </para> 1608 </listitem> 1609 </varlistentry> 1610 1611 <varlistentry id="guc-temp-buffers" xreflabel="temp_buffers"> 1612 <term><varname>temp_buffers</varname> (<type>integer</type>) 1613 <indexterm> 1614 <primary><varname>temp_buffers</varname> configuration parameter</primary> 1615 </indexterm> 1616 </term> 1617 <listitem> 1618 <para> 1619 Sets the maximum amount of memory used for temporary buffers within 1620 each database session. These are session-local buffers used only 1621 for access to temporary tables. 1622 If this value is specified without units, it is taken as blocks, 1623 that is <symbol>BLCKSZ</symbol> bytes, typically 8kB. 1624 The default is eight megabytes (<literal>8MB</literal>). 1625 (If <symbol>BLCKSZ</symbol> is not 8kB, the default value scales 1626 proportionally to it.) 1627 This setting can be changed within individual 1628 sessions, but only before the first use of temporary tables 1629 within the session; subsequent attempts to change the value will 1630 have no effect on that session. 1631 </para> 1632 1633 <para> 1634 A session will allocate temporary buffers as needed up to the limit 1635 given by <varname>temp_buffers</varname>. The cost of setting a large 1636 value in sessions that do not actually need many temporary 1637 buffers is only a buffer descriptor, or about 64 bytes, per 1638 increment in <varname>temp_buffers</varname>. However if a buffer is 1639 actually used an additional 8192 bytes will be consumed for it 1640 (or in general, <symbol>BLCKSZ</symbol> bytes). 1641 </para> 1642 </listitem> 1643 </varlistentry> 1644 1645 <varlistentry id="guc-max-prepared-transactions" xreflabel="max_prepared_transactions"> 1646 <term><varname>max_prepared_transactions</varname> (<type>integer</type>) 1647 <indexterm> 1648 <primary><varname>max_prepared_transactions</varname> configuration parameter</primary> 1649 </indexterm> 1650 </term> 1651 <listitem> 1652 <para> 1653 Sets the maximum number of transactions that can be in the 1654 <quote>prepared</quote> state simultaneously (see <xref 1655 linkend="sql-prepare-transaction"/>). 1656 Setting this parameter to zero (which is the default) 1657 disables the prepared-transaction feature. 1658 This parameter can only be set at server start. 1659 </para> 1660 1661 <para> 1662 If you are not planning to use prepared transactions, this parameter 1663 should be set to zero to prevent accidental creation of prepared 1664 transactions. If you are using prepared transactions, you will 1665 probably want <varname>max_prepared_transactions</varname> to be at 1666 least as large as <xref linkend="guc-max-connections"/>, so that every 1667 session can have a prepared transaction pending. 1668 </para> 1669 1670 <para> 1671 When running a standby server, you must set this parameter to the 1672 same or higher value than on the master server. Otherwise, queries 1673 will not be allowed in the standby server. 1674 </para> 1675 </listitem> 1676 </varlistentry> 1677 1678 <varlistentry id="guc-work-mem" xreflabel="work_mem"> 1679 <term><varname>work_mem</varname> (<type>integer</type>) 1680 <indexterm> 1681 <primary><varname>work_mem</varname> configuration parameter</primary> 1682 </indexterm> 1683 </term> 1684 <listitem> 1685 <para> 1686 Sets the base maximum amount of memory to be used by a query operation 1687 (such as a sort or hash table) before writing to temporary disk files. 1688 If this value is specified without units, it is taken as kilobytes. 1689 The default value is four megabytes (<literal>4MB</literal>). 1690 Note that for a complex query, several sort or hash operations might be 1691 running in parallel; each operation will generally be allowed 1692 to use as much memory as this value specifies before it starts 1693 to write data into temporary files. Also, several running 1694 sessions could be doing such operations concurrently. 1695 Therefore, the total memory used could be many times the value 1696 of <varname>work_mem</varname>; it is necessary to keep this 1697 fact in mind when choosing the value. Sort operations are used 1698 for <literal>ORDER BY</literal>, <literal>DISTINCT</literal>, 1699 and merge joins. 1700 Hash tables are used in hash joins, hash-based aggregation, and 1701 hash-based processing of <literal>IN</literal> subqueries. 1702 </para> 1703 <para> 1704 Hash-based operations are generally more sensitive to memory 1705 availability than equivalent sort-based operations. The 1706 memory available for hash tables is computed by multiplying 1707 <varname>work_mem</varname> by 1708 <varname>hash_mem_multiplier</varname>. This makes it 1709 possible for hash-based operations to use an amount of memory 1710 that exceeds the usual <varname>work_mem</varname> base 1711 amount. 1712 </para> 1713 </listitem> 1714 </varlistentry> 1715 1716 <varlistentry id="guc-hash-mem-multiplier" xreflabel="hash_mem_multiplier"> 1717 <term><varname>hash_mem_multiplier</varname> (<type>floating point</type>) 1718 <indexterm> 1719 <primary><varname>hash_mem_multiplier</varname> configuration parameter</primary> 1720 </indexterm> 1721 </term> 1722 <listitem> 1723 <para> 1724 Used to compute the maximum amount of memory that hash-based 1725 operations can use. The final limit is determined by 1726 multiplying <varname>work_mem</varname> by 1727 <varname>hash_mem_multiplier</varname>. The default value is 1728 1.0, which makes hash-based operations subject to the same 1729 simple <varname>work_mem</varname> maximum as sort-based 1730 operations. 1731 </para> 1732 <para> 1733 Consider increasing <varname>hash_mem_multiplier</varname> in 1734 environments where spilling by query operations is a regular 1735 occurrence, especially when simply increasing 1736 <varname>work_mem</varname> results in memory pressure (memory 1737 pressure typically takes the form of intermittent out of 1738 memory errors). A setting of 1.5 or 2.0 may be effective with 1739 mixed workloads. Higher settings in the range of 2.0 - 8.0 or 1740 more may be effective in environments where 1741 <varname>work_mem</varname> has already been increased to 40MB 1742 or more. 1743 </para> 1744 </listitem> 1745 </varlistentry> 1746 1747 <varlistentry id="guc-maintenance-work-mem" xreflabel="maintenance_work_mem"> 1748 <term><varname>maintenance_work_mem</varname> (<type>integer</type>) 1749 <indexterm> 1750 <primary><varname>maintenance_work_mem</varname> configuration parameter</primary> 1751 </indexterm> 1752 </term> 1753 <listitem> 1754 <para> 1755 Specifies the maximum amount of memory to be used by maintenance 1756 operations, such as <command>VACUUM</command>, <command>CREATE 1757 INDEX</command>, and <command>ALTER TABLE ADD FOREIGN KEY</command>. 1758 If this value is specified without units, it is taken as kilobytes. 1759 It defaults 1760 to 64 megabytes (<literal>64MB</literal>). Since only one of these 1761 operations can be executed at a time by a database session, and 1762 an installation normally doesn't have many of them running 1763 concurrently, it's safe to set this value significantly larger 1764 than <varname>work_mem</varname>. Larger settings might improve 1765 performance for vacuuming and for restoring database dumps. 1766 </para> 1767 <para> 1768 Note that when autovacuum runs, up to 1769 <xref linkend="guc-autovacuum-max-workers"/> times this memory 1770 may be allocated, so be careful not to set the default value 1771 too high. It may be useful to control for this by separately 1772 setting <xref linkend="guc-autovacuum-work-mem"/>. 1773 </para> 1774 <para> 1775 Note that for the collection of dead tuple identifiers, 1776 <command>VACUUM</command> is only able to utilize up to a maximum of 1777 <literal>1GB</literal> of memory. 1778 </para> 1779 </listitem> 1780 </varlistentry> 1781 1782 <varlistentry id="guc-autovacuum-work-mem" xreflabel="autovacuum_work_mem"> 1783 <term><varname>autovacuum_work_mem</varname> (<type>integer</type>) 1784 <indexterm> 1785 <primary><varname>autovacuum_work_mem</varname> configuration parameter</primary> 1786 </indexterm> 1787 </term> 1788 <listitem> 1789 <para> 1790 Specifies the maximum amount of memory to be used by each 1791 autovacuum worker process. 1792 If this value is specified without units, it is taken as kilobytes. 1793 It defaults to -1, indicating that 1794 the value of <xref linkend="guc-maintenance-work-mem"/> should 1795 be used instead. The setting has no effect on the behavior of 1796 <command>VACUUM</command> when run in other contexts. 1797 This parameter can only be set in the 1798 <filename>postgresql.conf</filename> file or on the server command 1799 line. 1800 </para> 1801 <para> 1802 For the collection of dead tuple identifiers, autovacuum is only able 1803 to utilize up to a maximum of <literal>1GB</literal> of memory, so 1804 setting <varname>autovacuum_work_mem</varname> to a value higher than 1805 that has no effect on the number of dead tuples that autovacuum can 1806 collect while scanning a table. 1807 </para> 1808 </listitem> 1809 </varlistentry> 1810 1811 <varlistentry id="guc-logical-decoding-work-mem" xreflabel="logical_decoding_work_mem"> 1812 <term><varname>logical_decoding_work_mem</varname> (<type>integer</type>) 1813 <indexterm> 1814 <primary><varname>logical_decoding_work_mem</varname> configuration parameter</primary> 1815 </indexterm> 1816 </term> 1817 <listitem> 1818 <para> 1819 Specifies the maximum amount of memory to be used by logical decoding, 1820 before some of the decoded changes are written to local disk. This 1821 limits the amount of memory used by logical streaming replication 1822 connections. It defaults to 64 megabytes (<literal>64MB</literal>). 1823 Since each replication connection only uses a single buffer of this size, 1824 and an installation normally doesn't have many such connections 1825 concurrently (as limited by <varname>max_wal_senders</varname>), it's 1826 safe to set this value significantly higher than <varname>work_mem</varname>, 1827 reducing the amount of decoded changes written to disk. 1828 </para> 1829 </listitem> 1830 </varlistentry> 1831 1832 <varlistentry id="guc-max-stack-depth" xreflabel="max_stack_depth"> 1833 <term><varname>max_stack_depth</varname> (<type>integer</type>) 1834 <indexterm> 1835 <primary><varname>max_stack_depth</varname> configuration parameter</primary> 1836 </indexterm> 1837 </term> 1838 <listitem> 1839 <para> 1840 Specifies the maximum safe depth of the server's execution stack. 1841 The ideal setting for this parameter is the actual stack size limit 1842 enforced by the kernel (as set by <literal>ulimit -s</literal> or local 1843 equivalent), less a safety margin of a megabyte or so. The safety 1844 margin is needed because the stack depth is not checked in every 1845 routine in the server, but only in key potentially-recursive routines. 1846 If this value is specified without units, it is taken as kilobytes. 1847 The default setting is two megabytes (<literal>2MB</literal>), which 1848 is conservatively small and unlikely to risk crashes. However, 1849 it might be too small to allow execution of complex functions. 1850 Only superusers can change this setting. 1851 </para> 1852 1853 <para> 1854 Setting <varname>max_stack_depth</varname> higher than 1855 the actual kernel limit will mean that a runaway recursive function 1856 can crash an individual backend process. On platforms where 1857 <productname>PostgreSQL</productname> can determine the kernel limit, 1858 the server will not allow this variable to be set to an unsafe 1859 value. However, not all platforms provide the information, 1860 so caution is recommended in selecting a value. 1861 </para> 1862 </listitem> 1863 </varlistentry> 1864 1865 <varlistentry id="guc-shared-memory-type" xreflabel="shared_memory_type"> 1866 <term><varname>shared_memory_type</varname> (<type>enum</type>) 1867 <indexterm> 1868 <primary><varname>shared_memory_type</varname> configuration parameter</primary> 1869 </indexterm> 1870 </term> 1871 <listitem> 1872 <para> 1873 Specifies the shared memory implementation that the server 1874 should use for the main shared memory region that holds 1875 <productname>PostgreSQL</productname>'s shared buffers and other 1876 shared data. Possible values are <literal>mmap</literal> (for 1877 anonymous shared memory allocated using <function>mmap</function>), 1878 <literal>sysv</literal> (for System V shared memory allocated via 1879 <function>shmget</function>) and <literal>windows</literal> (for Windows 1880 shared memory). Not all values are supported on all platforms; the 1881 first supported option is the default for that platform. The use of 1882 the <literal>sysv</literal> option, which is not the default on any 1883 platform, is generally discouraged because it typically requires 1884 non-default kernel settings to allow for large allocations (see <xref 1885 linkend="sysvipc"/>). 1886 </para> 1887 </listitem> 1888 </varlistentry> 1889 1890 <varlistentry id="guc-dynamic-shared-memory-type" xreflabel="dynamic_shared_memory_type"> 1891 <term><varname>dynamic_shared_memory_type</varname> (<type>enum</type>) 1892 <indexterm> 1893 <primary><varname>dynamic_shared_memory_type</varname> configuration parameter</primary> 1894 </indexterm> 1895 </term> 1896 <listitem> 1897 <para> 1898 Specifies the dynamic shared memory implementation that the server 1899 should use. Possible values are <literal>posix</literal> (for POSIX shared 1900 memory allocated using <literal>shm_open</literal>), <literal>sysv</literal> 1901 (for System V shared memory allocated via <literal>shmget</literal>), 1902 <literal>windows</literal> (for Windows shared memory), 1903 and <literal>mmap</literal> (to simulate shared memory using 1904 memory-mapped files stored in the data directory). 1905 Not all values are supported on all platforms; the first supported 1906 option is the default for that platform. The use of the 1907 <literal>mmap</literal> option, which is not the default on any platform, 1908 is generally discouraged because the operating system may write 1909 modified pages back to disk repeatedly, increasing system I/O load; 1910 however, it may be useful for debugging, when the 1911 <literal>pg_dynshmem</literal> directory is stored on a RAM disk, or when 1912 other shared memory facilities are not available. 1913 </para> 1914 </listitem> 1915 </varlistentry> 1916 1917 </variablelist> 1918 </sect2> 1919 1920 <sect2 id="runtime-config-resource-disk"> 1921 <title>Disk</title> 1922 1923 <variablelist> 1924 <varlistentry id="guc-temp-file-limit" xreflabel="temp_file_limit"> 1925 <term><varname>temp_file_limit</varname> (<type>integer</type>) 1926 <indexterm> 1927 <primary><varname>temp_file_limit</varname> configuration parameter</primary> 1928 </indexterm> 1929 </term> 1930 <listitem> 1931 <para> 1932 Specifies the maximum amount of disk space that a process can use 1933 for temporary files, such as sort and hash temporary files, or the 1934 storage file for a held cursor. A transaction attempting to exceed 1935 this limit will be canceled. 1936 If this value is specified without units, it is taken as kilobytes. 1937 <literal>-1</literal> (the default) means no limit. 1938 Only superusers can change this setting. 1939 </para> 1940 <para> 1941 This setting constrains the total space used at any instant by all 1942 temporary files used by a given <productname>PostgreSQL</productname> process. 1943 It should be noted that disk space used for explicit temporary 1944 tables, as opposed to temporary files used behind-the-scenes in query 1945 execution, does <emphasis>not</emphasis> count against this limit. 1946 </para> 1947 </listitem> 1948 </varlistentry> 1949 1950 </variablelist> 1951 </sect2> 1952 1953 <sect2 id="runtime-config-resource-kernel"> 1954 <title>Kernel Resource Usage</title> 1955 1956 <variablelist> 1957 <varlistentry id="guc-max-files-per-process" xreflabel="max_files_per_process"> 1958 <term><varname>max_files_per_process</varname> (<type>integer</type>) 1959 <indexterm> 1960 <primary><varname>max_files_per_process</varname> configuration parameter</primary> 1961 </indexterm> 1962 </term> 1963 <listitem> 1964 <para> 1965 Sets the maximum number of simultaneously open files allowed to each 1966 server subprocess. The default is one thousand files. If the kernel is enforcing 1967 a safe per-process limit, you don't need to worry about this setting. 1968 But on some platforms (notably, most BSD systems), the kernel will 1969 allow individual processes to open many more files than the system 1970 can actually support if many processes all try to open 1971 that many files. If you find yourself seeing <quote>Too many open 1972 files</quote> failures, try reducing this setting. 1973 This parameter can only be set at server start. 1974 </para> 1975 </listitem> 1976 </varlistentry> 1977 </variablelist> 1978 </sect2> 1979 1980 <sect2 id="runtime-config-resource-vacuum-cost"> 1981 <title>Cost-based Vacuum Delay</title> 1982 1983 <para> 1984 During the execution of <xref linkend="sql-vacuum"/> 1985 and <xref linkend="sql-analyze"/> 1986 commands, the system maintains an 1987 internal counter that keeps track of the estimated cost of the 1988 various I/O operations that are performed. When the accumulated 1989 cost reaches a limit (specified by 1990 <varname>vacuum_cost_limit</varname>), the process performing 1991 the operation will sleep for a short period of time, as specified by 1992 <varname>vacuum_cost_delay</varname>. Then it will reset the 1993 counter and continue execution. 1994 </para> 1995 1996 <para> 1997 The intent of this feature is to allow administrators to reduce 1998 the I/O impact of these commands on concurrent database 1999 activity. There are many situations where it is not 2000 important that maintenance commands like 2001 <command>VACUUM</command> and <command>ANALYZE</command> finish 2002 quickly; however, it is usually very important that these 2003 commands do not significantly interfere with the ability of the 2004 system to perform other database operations. Cost-based vacuum 2005 delay provides a way for administrators to achieve this. 2006 </para> 2007 2008 <para> 2009 This feature is disabled by default for manually issued 2010 <command>VACUUM</command> commands. To enable it, set the 2011 <varname>vacuum_cost_delay</varname> variable to a nonzero 2012 value. 2013 </para> 2014 2015 <variablelist> 2016 <varlistentry id="guc-vacuum-cost-delay" xreflabel="vacuum_cost_delay"> 2017 <term><varname>vacuum_cost_delay</varname> (<type>floating point</type>) 2018 <indexterm> 2019 <primary><varname>vacuum_cost_delay</varname> configuration parameter</primary> 2020 </indexterm> 2021 </term> 2022 <listitem> 2023 <para> 2024 The amount of time that the process will sleep 2025 when the cost limit has been exceeded. 2026 If this value is specified without units, it is taken as milliseconds. 2027 The default value is zero, which disables the cost-based vacuum 2028 delay feature. Positive values enable cost-based vacuuming. 2029 </para> 2030 2031 <para> 2032 When using cost-based vacuuming, appropriate values for 2033 <varname>vacuum_cost_delay</varname> are usually quite small, perhaps 2034 less than 1 millisecond. While <varname>vacuum_cost_delay</varname> 2035 can be set to fractional-millisecond values, such delays may not be 2036 measured accurately on older platforms. On such platforms, 2037 increasing <command>VACUUM</command>'s throttled resource consumption 2038 above what you get at 1ms will require changing the other vacuum cost 2039 parameters. You should, nonetheless, 2040 keep <varname>vacuum_cost_delay</varname> as small as your platform 2041 will consistently measure; large delays are not helpful. 2042 </para> 2043 </listitem> 2044 </varlistentry> 2045 2046 <varlistentry id="guc-vacuum-cost-page-hit" xreflabel="vacuum_cost_page_hit"> 2047 <term><varname>vacuum_cost_page_hit</varname> (<type>integer</type>) 2048 <indexterm> 2049 <primary><varname>vacuum_cost_page_hit</varname> configuration parameter</primary> 2050 </indexterm> 2051 </term> 2052 <listitem> 2053 <para> 2054 The estimated cost for vacuuming a buffer found in the shared buffer 2055 cache. It represents the cost to lock the buffer pool, lookup 2056 the shared hash table and scan the content of the page. The 2057 default value is one. 2058 </para> 2059 </listitem> 2060 </varlistentry> 2061 2062 <varlistentry id="guc-vacuum-cost-page-miss" xreflabel="vacuum_cost_page_miss"> 2063 <term><varname>vacuum_cost_page_miss</varname> (<type>integer</type>) 2064 <indexterm> 2065 <primary><varname>vacuum_cost_page_miss</varname> configuration parameter</primary> 2066 </indexterm> 2067 </term> 2068 <listitem> 2069 <para> 2070 The estimated cost for vacuuming a buffer that has to be read from 2071 disk. This represents the effort to lock the buffer pool, 2072 lookup the shared hash table, read the desired block in from 2073 the disk and scan its content. The default value is 10. 2074 </para> 2075 </listitem> 2076 </varlistentry> 2077 2078 <varlistentry id="guc-vacuum-cost-page-dirty" xreflabel="vacuum_cost_page_dirty"> 2079 <term><varname>vacuum_cost_page_dirty</varname> (<type>integer</type>) 2080 <indexterm> 2081 <primary><varname>vacuum_cost_page_dirty</varname> configuration parameter</primary> 2082 </indexterm> 2083 </term> 2084 <listitem> 2085 <para> 2086 The estimated cost charged when vacuum modifies a block that was 2087 previously clean. It represents the extra I/O required to 2088 flush the dirty block out to disk again. The default value is 2089 20. 2090 </para> 2091 </listitem> 2092 </varlistentry> 2093 2094 <varlistentry id="guc-vacuum-cost-limit" xreflabel="vacuum_cost_limit"> 2095 <term><varname>vacuum_cost_limit</varname> (<type>integer</type>) 2096 <indexterm> 2097 <primary><varname>vacuum_cost_limit</varname> configuration parameter</primary> 2098 </indexterm> 2099 </term> 2100 <listitem> 2101 <para> 2102 The accumulated cost that will cause the vacuuming process to sleep. 2103 The default value is 200. 2104 </para> 2105 </listitem> 2106 </varlistentry> 2107 </variablelist> 2108 2109 <note> 2110 <para> 2111 There are certain operations that hold critical locks and should 2112 therefore complete as quickly as possible. Cost-based vacuum 2113 delays do not occur during such operations. Therefore it is 2114 possible that the cost accumulates far higher than the specified 2115 limit. To avoid uselessly long delays in such cases, the actual 2116 delay is calculated as <varname>vacuum_cost_delay</varname> * 2117 <varname>accumulated_balance</varname> / 2118 <varname>vacuum_cost_limit</varname> with a maximum of 2119 <varname>vacuum_cost_delay</varname> * 4. 2120 </para> 2121 </note> 2122 </sect2> 2123 2124 <sect2 id="runtime-config-resource-background-writer"> 2125 <title>Background Writer</title> 2126 2127 <para> 2128 There is a separate server 2129 process called the <firstterm>background writer</firstterm>, whose function 2130 is to issue writes of <quote>dirty</quote> (new or modified) shared 2131 buffers. When the number of clean shared buffers appears to be 2132 insufficient, the background writer writes some dirty buffers to the 2133 file system and marks them as clean. This reduces the likelihood 2134 that server processes handling user queries will be unable to find 2135 clean buffers and have to write dirty buffers themselves. 2136 However, the background writer does cause a net overall 2137 increase in I/O load, because while a repeatedly-dirtied page might 2138 otherwise be written only once per checkpoint interval, the 2139 background writer might write it several times as it is dirtied 2140 in the same interval. The parameters discussed in this subsection 2141 can be used to tune the behavior for local needs. 2142 </para> 2143 2144 <variablelist> 2145 <varlistentry id="guc-bgwriter-delay" xreflabel="bgwriter_delay"> 2146 <term><varname>bgwriter_delay</varname> (<type>integer</type>) 2147 <indexterm> 2148 <primary><varname>bgwriter_delay</varname> configuration parameter</primary> 2149 </indexterm> 2150 </term> 2151 <listitem> 2152 <para> 2153 Specifies the delay between activity rounds for the 2154 background writer. In each round the writer issues writes 2155 for some number of dirty buffers (controllable by the 2156 following parameters). It then sleeps for 2157 the length of <varname>bgwriter_delay</varname>, and repeats. 2158 When there are no dirty buffers in the 2159 buffer pool, though, it goes into a longer sleep regardless of 2160 <varname>bgwriter_delay</varname>. 2161 If this value is specified without units, it is taken as milliseconds. 2162 The default value is 200 2163 milliseconds (<literal>200ms</literal>). Note that on many systems, the 2164 effective resolution of sleep delays is 10 milliseconds; setting 2165 <varname>bgwriter_delay</varname> to a value that is not a multiple of 10 2166 might have the same results as setting it to the next higher multiple 2167 of 10. This parameter can only be set in the 2168 <filename>postgresql.conf</filename> file or on the server command line. 2169 </para> 2170 </listitem> 2171 </varlistentry> 2172 2173 <varlistentry id="guc-bgwriter-lru-maxpages" xreflabel="bgwriter_lru_maxpages"> 2174 <term><varname>bgwriter_lru_maxpages</varname> (<type>integer</type>) 2175 <indexterm> 2176 <primary><varname>bgwriter_lru_maxpages</varname> configuration parameter</primary> 2177 </indexterm> 2178 </term> 2179 <listitem> 2180 <para> 2181 In each round, no more than this many buffers will be written 2182 by the background writer. Setting this to zero disables 2183 background writing. (Note that checkpoints, which are managed by 2184 a separate, dedicated auxiliary process, are unaffected.) 2185 The default value is 100 buffers. 2186 This parameter can only be set in the <filename>postgresql.conf</filename> 2187 file or on the server command line. 2188 </para> 2189 </listitem> 2190 </varlistentry> 2191 2192 <varlistentry id="guc-bgwriter-lru-multiplier" xreflabel="bgwriter_lru_multiplier"> 2193 <term><varname>bgwriter_lru_multiplier</varname> (<type>floating point</type>) 2194 <indexterm> 2195 <primary><varname>bgwriter_lru_multiplier</varname> configuration parameter</primary> 2196 </indexterm> 2197 </term> 2198 <listitem> 2199 <para> 2200 The number of dirty buffers written in each round is based on the 2201 number of new buffers that have been needed by server processes 2202 during recent rounds. The average recent need is multiplied by 2203 <varname>bgwriter_lru_multiplier</varname> to arrive at an estimate of the 2204 number of buffers that will be needed during the next round. Dirty 2205 buffers are written until there are that many clean, reusable buffers 2206 available. (However, no more than <varname>bgwriter_lru_maxpages</varname> 2207 buffers will be written per round.) 2208 Thus, a setting of 1.0 represents a <quote>just in time</quote> policy 2209 of writing exactly the number of buffers predicted to be needed. 2210 Larger values provide some cushion against spikes in demand, 2211 while smaller values intentionally leave writes to be done by 2212 server processes. 2213 The default is 2.0. 2214 This parameter can only be set in the <filename>postgresql.conf</filename> 2215 file or on the server command line. 2216 </para> 2217 </listitem> 2218 </varlistentry> 2219 2220 <varlistentry id="guc-bgwriter-flush-after" xreflabel="bgwriter_flush_after"> 2221 <term><varname>bgwriter_flush_after</varname> (<type>integer</type>) 2222 <indexterm> 2223 <primary><varname>bgwriter_flush_after</varname> configuration parameter</primary> 2224 </indexterm> 2225 </term> 2226 <listitem> 2227 <para> 2228 Whenever more than this amount of data has 2229 been written by the background writer, attempt to force the OS to issue these 2230 writes to the underlying storage. Doing so will limit the amount of 2231 dirty data in the kernel's page cache, reducing the likelihood of 2232 stalls when an <function>fsync</function> is issued at the end of a checkpoint, or when 2233 the OS writes data back in larger batches in the background. Often 2234 that will result in greatly reduced transaction latency, but there 2235 also are some cases, especially with workloads that are bigger than 2236 <xref linkend="guc-shared-buffers"/>, but smaller than the OS's page 2237 cache, where performance might degrade. This setting may have no 2238 effect on some platforms. 2239 If this value is specified without units, it is taken as blocks, 2240 that is <symbol>BLCKSZ</symbol> bytes, typically 8kB. 2241 The valid range is between 2242 <literal>0</literal>, which disables forced writeback, and 2243 <literal>2MB</literal>. The default is <literal>512kB</literal> on Linux, 2244 <literal>0</literal> elsewhere. (If <symbol>BLCKSZ</symbol> is not 8kB, 2245 the default and maximum values scale proportionally to it.) 2246 This parameter can only be set in the <filename>postgresql.conf</filename> 2247 file or on the server command line. 2248 </para> 2249 </listitem> 2250 </varlistentry> 2251 </variablelist> 2252 2253 <para> 2254 Smaller values of <varname>bgwriter_lru_maxpages</varname> and 2255 <varname>bgwriter_lru_multiplier</varname> reduce the extra I/O load 2256 caused by the background writer, but make it more likely that server 2257 processes will have to issue writes for themselves, delaying interactive 2258 queries. 2259 </para> 2260 </sect2> 2261 2262 <sect2 id="runtime-config-resource-async-behavior"> 2263 <title>Asynchronous Behavior</title> 2264 2265 <variablelist> 2266 <varlistentry id="guc-effective-io-concurrency" xreflabel="effective_io_concurrency"> 2267 <term><varname>effective_io_concurrency</varname> (<type>integer</type>) 2268 <indexterm> 2269 <primary><varname>effective_io_concurrency</varname> configuration parameter</primary> 2270 </indexterm> 2271 </term> 2272 <listitem> 2273 <para> 2274 Sets the number of concurrent disk I/O operations that 2275 <productname>PostgreSQL</productname> expects can be executed 2276 simultaneously. Raising this value will increase the number of I/O 2277 operations that any individual <productname>PostgreSQL</productname> session 2278 attempts to initiate in parallel. The allowed range is 1 to 1000, 2279 or zero to disable issuance of asynchronous I/O requests. Currently, 2280 this setting only affects bitmap heap scans. 2281 </para> 2282 2283 <para> 2284 For magnetic drives, a good starting point for this setting is the 2285 number of separate 2286 drives comprising a RAID 0 stripe or RAID 1 mirror being used for the 2287 database. (For RAID 5 the parity drive should not be counted.) 2288 However, if the database is often busy with multiple queries issued in 2289 concurrent sessions, lower values may be sufficient to keep the disk 2290 array busy. A value higher than needed to keep the disks busy will 2291 only result in extra CPU overhead. 2292 SSDs and other memory-based storage can often process many 2293 concurrent requests, so the best value might be in the hundreds. 2294 </para> 2295 2296 <para> 2297 Asynchronous I/O depends on an effective <function>posix_fadvise</function> 2298 function, which some operating systems lack. If the function is not 2299 present then setting this parameter to anything but zero will result 2300 in an error. On some operating systems (e.g., Solaris), the function 2301 is present but does not actually do anything. 2302 </para> 2303 2304 <para> 2305 The default is 1 on supported systems, otherwise 0. This value can 2306 be overridden for tables in a particular tablespace by setting the 2307 tablespace parameter of the same name (see 2308 <xref linkend="sql-altertablespace"/>). 2309 </para> 2310 </listitem> 2311 </varlistentry> 2312 2313 <varlistentry id="guc-maintenance-io-concurrency" xreflabel="maintenance_io_concurrency"> 2314 <term><varname>maintenance_io_concurrency</varname> (<type>integer</type>) 2315 <indexterm> 2316 <primary><varname>maintenance_io_concurrency</varname> configuration parameter</primary> 2317 </indexterm> 2318 </term> 2319 <listitem> 2320 <para> 2321 Similar to <varname>effective_io_concurrency</varname>, but used 2322 for maintenance work that is done on behalf of many client sessions. 2323 </para> 2324 <para> 2325 The default is 10 on supported systems, otherwise 0. This value can 2326 be overridden for tables in a particular tablespace by setting the 2327 tablespace parameter of the same name (see 2328 <xref linkend="sql-altertablespace"/>). 2329 </para> 2330 </listitem> 2331 </varlistentry> 2332 2333 <varlistentry id="guc-max-worker-processes" xreflabel="max_worker_processes"> 2334 <term><varname>max_worker_processes</varname> (<type>integer</type>) 2335 <indexterm> 2336 <primary><varname>max_worker_processes</varname> configuration parameter</primary> 2337 </indexterm> 2338 </term> 2339 <listitem> 2340 <para> 2341 Sets the maximum number of background processes that the system 2342 can support. This parameter can only be set at server start. The 2343 default is 8. 2344 </para> 2345 2346 <para> 2347 When running a standby server, you must set this parameter to the 2348 same or higher value than on the master server. Otherwise, queries 2349 will not be allowed in the standby server. 2350 </para> 2351 2352 <para> 2353 When changing this value, consider also adjusting 2354 <xref linkend="guc-max-parallel-workers"/>, 2355 <xref linkend="guc-max-parallel-workers-maintenance"/>, and 2356 <xref linkend="guc-max-parallel-workers-per-gather"/>. 2357 </para> 2358 </listitem> 2359 </varlistentry> 2360 2361 <varlistentry id="guc-max-parallel-workers-per-gather" xreflabel="max_parallel_workers_per_gather"> 2362 <term><varname>max_parallel_workers_per_gather</varname> (<type>integer</type>) 2363 <indexterm> 2364 <primary><varname>max_parallel_workers_per_gather</varname> configuration parameter</primary> 2365 </indexterm> 2366 </term> 2367 <listitem> 2368 <para> 2369 Sets the maximum number of workers that can be started by a single 2370 <literal>Gather</literal> or <literal>Gather Merge</literal> node. 2371 Parallel workers are taken from the pool of processes established by 2372 <xref linkend="guc-max-worker-processes"/>, limited by 2373 <xref linkend="guc-max-parallel-workers"/>. Note that the requested 2374 number of workers may not actually be available at run time. If this 2375 occurs, the plan will run with fewer workers than expected, which may 2376 be inefficient. The default value is 2. Setting this value to 0 2377 disables parallel query execution. 2378 </para> 2379 2380 <para> 2381 Note that parallel queries may consume very substantially more 2382 resources than non-parallel queries, because each worker process is 2383 a completely separate process which has roughly the same impact on the 2384 system as an additional user session. This should be taken into 2385 account when choosing a value for this setting, as well as when 2386 configuring other settings that control resource utilization, such 2387 as <xref linkend="guc-work-mem"/>. Resource limits such as 2388 <varname>work_mem</varname> are applied individually to each worker, 2389 which means the total utilization may be much higher across all 2390 processes than it would normally be for any single process. 2391 For example, a parallel query using 4 workers may use up to 5 times 2392 as much CPU time, memory, I/O bandwidth, and so forth as a query which 2393 uses no workers at all. 2394 </para> 2395 2396 <para> 2397 For more information on parallel query, see 2398 <xref linkend="parallel-query"/>. 2399 </para> 2400 </listitem> 2401 </varlistentry> 2402 2403 <varlistentry id="guc-max-parallel-workers-maintenance" xreflabel="max_parallel_maintenance_workers"> 2404 <term><varname>max_parallel_maintenance_workers</varname> (<type>integer</type>) 2405 <indexterm> 2406 <primary><varname>max_parallel_maintenance_workers</varname> configuration parameter</primary> 2407 </indexterm> 2408 </term> 2409 <listitem> 2410 <para> 2411 Sets the maximum number of parallel workers that can be 2412 started by a single utility command. Currently, the parallel 2413 utility commands that support the use of parallel workers are 2414 <command>CREATE INDEX</command> only when building a B-tree index, 2415 and <command>VACUUM</command> without <literal>FULL</literal> 2416 option. Parallel workers are taken from the pool of processes 2417 established by <xref linkend="guc-max-worker-processes"/>, limited 2418 by <xref linkend="guc-max-parallel-workers"/>. Note that the requested 2419 number of workers may not actually be available at run time. 2420 If this occurs, the utility operation will run with fewer 2421 workers than expected. The default value is 2. Setting this 2422 value to 0 disables the use of parallel workers by utility 2423 commands. 2424 </para> 2425 2426 <para> 2427 Note that parallel utility commands should not consume 2428 substantially more memory than equivalent non-parallel 2429 operations. This strategy differs from that of parallel 2430 query, where resource limits generally apply per worker 2431 process. Parallel utility commands treat the resource limit 2432 <varname>maintenance_work_mem</varname> as a limit to be applied to 2433 the entire utility command, regardless of the number of 2434 parallel worker processes. However, parallel utility 2435 commands may still consume substantially more CPU resources 2436 and I/O bandwidth. 2437 </para> 2438 </listitem> 2439 </varlistentry> 2440 2441 <varlistentry id="guc-max-parallel-workers" xreflabel="max_parallel_workers"> 2442 <term><varname>max_parallel_workers</varname> (<type>integer</type>) 2443 <indexterm> 2444 <primary><varname>max_parallel_workers</varname> configuration parameter</primary> 2445 </indexterm> 2446 </term> 2447 <listitem> 2448 <para> 2449 Sets the maximum number of workers that the system can support for 2450 parallel operations. The default value is 8. When increasing or 2451 decreasing this value, consider also adjusting 2452 <xref linkend="guc-max-parallel-workers-maintenance"/> and 2453 <xref linkend="guc-max-parallel-workers-per-gather"/>. 2454 Also, note that a setting for this value which is higher than 2455 <xref linkend="guc-max-worker-processes"/> will have no effect, 2456 since parallel workers are taken from the pool of worker processes 2457 established by that setting. 2458 </para> 2459 </listitem> 2460 </varlistentry> 2461 2462 <varlistentry id="guc-backend-flush-after" xreflabel="backend_flush_after"> 2463 <term><varname>backend_flush_after</varname> (<type>integer</type>) 2464 <indexterm> 2465 <primary><varname>backend_flush_after</varname> configuration parameter</primary> 2466 </indexterm> 2467 </term> 2468 <listitem> 2469 <para> 2470 Whenever more than this amount of data has 2471 been written by a single backend, attempt to force the OS to issue 2472 these writes to the underlying storage. Doing so will limit the 2473 amount of dirty data in the kernel's page cache, reducing the 2474 likelihood of stalls when an <function>fsync</function> is issued at the end of a 2475 checkpoint, or when the OS writes data back in larger batches in the 2476 background. Often that will result in greatly reduced transaction 2477 latency, but there also are some cases, especially with workloads 2478 that are bigger than <xref linkend="guc-shared-buffers"/>, but smaller 2479 than the OS's page cache, where performance might degrade. This 2480 setting may have no effect on some platforms. 2481 If this value is specified without units, it is taken as blocks, 2482 that is <symbol>BLCKSZ</symbol> bytes, typically 8kB. 2483 The valid range is 2484 between <literal>0</literal>, which disables forced writeback, 2485 and <literal>2MB</literal>. The default is <literal>0</literal>, i.e., no 2486 forced writeback. (If <symbol>BLCKSZ</symbol> is not 8kB, 2487 the maximum value scales proportionally to it.) 2488 </para> 2489 </listitem> 2490 </varlistentry> 2491 2492 <varlistentry id="guc-old-snapshot-threshold" xreflabel="old_snapshot_threshold"> 2493 <term><varname>old_snapshot_threshold</varname> (<type>integer</type>) 2494 <indexterm> 2495 <primary><varname>old_snapshot_threshold</varname> configuration parameter</primary> 2496 </indexterm> 2497 </term> 2498 <listitem> 2499 <para> 2500 Sets the minimum amount of time that a query snapshot can be used 2501 without risk of a <quote>snapshot too old</quote> error occurring 2502 when using the snapshot. Data that has been dead for longer than 2503 this threshold is allowed to be vacuumed away. This can help 2504 prevent bloat in the face of snapshots which remain in use for a 2505 long time. To prevent incorrect results due to cleanup of data which 2506 would otherwise be visible to the snapshot, an error is generated 2507 when the snapshot is older than this threshold and the snapshot is 2508 used to read a page which has been modified since the snapshot was 2509 built. 2510 </para> 2511 2512 <para> 2513 If this value is specified without units, it is taken as minutes. 2514 A value of <literal>-1</literal> (the default) disables this feature, 2515 effectively setting the snapshot age limit to infinity. 2516 This parameter can only be set at server start. 2517 </para> 2518 2519 <para> 2520 Useful values for production work probably range from a small number 2521 of hours to a few days. Small values (such as <literal>0</literal> or 2522 <literal>1min</literal>) are only allowed because they may sometimes be 2523 useful for testing. While a setting as high as <literal>60d</literal> is 2524 allowed, please note that in many workloads extreme bloat or 2525 transaction ID wraparound may occur in much shorter time frames. 2526 </para> 2527 2528 <para> 2529 When this feature is enabled, freed space at the end of a relation 2530 cannot be released to the operating system, since that could remove 2531 information needed to detect the <quote>snapshot too old</quote> 2532 condition. All space allocated to a relation remains associated with 2533 that relation for reuse only within that relation unless explicitly 2534 freed (for example, with <command>VACUUM FULL</command>). 2535 </para> 2536 2537 <para> 2538 This setting does not attempt to guarantee that an error will be 2539 generated under any particular circumstances. In fact, if the 2540 correct results can be generated from (for example) a cursor which 2541 has materialized a result set, no error will be generated even if the 2542 underlying rows in the referenced table have been vacuumed away. 2543 Some tables cannot safely be vacuumed early, and so will not be 2544 affected by this setting, such as system catalogs. For such tables 2545 this setting will neither reduce bloat nor create a possibility 2546 of a <quote>snapshot too old</quote> error on scanning. 2547 </para> 2548 </listitem> 2549 </varlistentry> 2550 </variablelist> 2551 </sect2> 2552 </sect1> 2553 2554 <sect1 id="runtime-config-wal"> 2555 <title>Write Ahead Log</title> 2556 2557 <para> 2558 For additional information on tuning these settings, 2559 see <xref linkend="wal-configuration"/>. 2560 </para> 2561 2562 <sect2 id="runtime-config-wal-settings"> 2563 <title>Settings</title> 2564 <variablelist> 2565 2566 <varlistentry id="guc-wal-level" xreflabel="wal_level"> 2567 <term><varname>wal_level</varname> (<type>enum</type>) 2568 <indexterm> 2569 <primary><varname>wal_level</varname> configuration parameter</primary> 2570 </indexterm> 2571 </term> 2572 <listitem> 2573 <para> 2574 <varname>wal_level</varname> determines how much information is written to 2575 the WAL. The default value is <literal>replica</literal>, which writes enough 2576 data to support WAL archiving and replication, including running 2577 read-only queries on a standby server. <literal>minimal</literal> removes all 2578 logging except the information required to recover from a crash or 2579 immediate shutdown. Finally, 2580 <literal>logical</literal> adds information necessary to support logical 2581 decoding. Each level includes the information logged at all lower 2582 levels. This parameter can only be set at server start. 2583 </para> 2584 <para> 2585 In <literal>minimal</literal> level, no information is logged for 2586 permanent relations for the remainder of a transaction that creates or 2587 rewrites them. This can make operations much faster (see 2588 <xref linkend="populate-pitr"/>). Operations that initiate this 2589 optimization include: 2590 <simplelist> 2591 <member><command>ALTER ... SET TABLESPACE</command></member> 2592 <member><command>CLUSTER</command></member> 2593 <member><command>CREATE TABLE</command></member> 2594 <member><command>REFRESH MATERIALIZED VIEW</command> 2595 (without <option>CONCURRENTLY</option>)</member> 2596 <member><command>REINDEX</command></member> 2597 <member><command>TRUNCATE</command></member> 2598 </simplelist> 2599 But minimal WAL does not contain enough information to reconstruct the 2600 data from a base backup and the WAL logs, so <literal>replica</literal> or 2601 higher must be used to enable WAL archiving 2602 (<xref linkend="guc-archive-mode"/>) and streaming replication. 2603 </para> 2604 <para> 2605 In <literal>logical</literal> level, the same information is logged as 2606 with <literal>replica</literal>, plus information needed to allow 2607 extracting logical change sets from the WAL. Using a level of 2608 <literal>logical</literal> will increase the WAL volume, particularly if many 2609 tables are configured for <literal>REPLICA IDENTITY FULL</literal> and 2610 many <command>UPDATE</command> and <command>DELETE</command> statements are 2611 executed. 2612 </para> 2613 <para> 2614 In releases prior to 9.6, this parameter also allowed the 2615 values <literal>archive</literal> and <literal>hot_standby</literal>. 2616 These are still accepted but mapped to <literal>replica</literal>. 2617 </para> 2618 </listitem> 2619 </varlistentry> 2620 2621 <varlistentry id="guc-fsync" xreflabel="fsync"> 2622 <term><varname>fsync</varname> (<type>boolean</type>) 2623 <indexterm> 2624 <primary><varname>fsync</varname> configuration parameter</primary> 2625 </indexterm> 2626 </term> 2627 <listitem> 2628 <para> 2629 If this parameter is on, the <productname>PostgreSQL</productname> server 2630 will try to make sure that updates are physically written to 2631 disk, by issuing <function>fsync()</function> system calls or various 2632 equivalent methods (see <xref linkend="guc-wal-sync-method"/>). 2633 This ensures that the database cluster can recover to a 2634 consistent state after an operating system or hardware crash. 2635 </para> 2636 2637 <para> 2638 While turning off <varname>fsync</varname> is often a performance 2639 benefit, this can result in unrecoverable data corruption in 2640 the event of a power failure or system crash. Thus it 2641 is only advisable to turn off <varname>fsync</varname> if 2642 you can easily recreate your entire database from external 2643 data. 2644 </para> 2645 2646 <para> 2647 Examples of safe circumstances for turning off 2648 <varname>fsync</varname> include the initial loading of a new 2649 database cluster from a backup file, using a database cluster 2650 for processing a batch of data after which the database 2651 will be thrown away and recreated, 2652 or for a read-only database clone which 2653 gets recreated frequently and is not used for failover. High 2654 quality hardware alone is not a sufficient justification for 2655 turning off <varname>fsync</varname>. 2656 </para> 2657 2658 <para> 2659 For reliable recovery when changing <varname>fsync</varname> 2660 off to on, it is necessary to force all modified buffers in the 2661 kernel to durable storage. This can be done while the cluster 2662 is shutdown or while <varname>fsync</varname> is on by running <command>initdb 2663 --sync-only</command>, running <command>sync</command>, unmounting the 2664 file system, or rebooting the server. 2665 </para> 2666 2667 <para> 2668 In many situations, turning off <xref linkend="guc-synchronous-commit"/> 2669 for noncritical transactions can provide much of the potential 2670 performance benefit of turning off <varname>fsync</varname>, without 2671 the attendant risks of data corruption. 2672 </para> 2673 2674 <para> 2675 <varname>fsync</varname> can only be set in the <filename>postgresql.conf</filename> 2676 file or on the server command line. 2677 If you turn this parameter off, also consider turning off 2678 <xref linkend="guc-full-page-writes"/>. 2679 </para> 2680 </listitem> 2681 </varlistentry> 2682 2683 <varlistentry id="guc-synchronous-commit" xreflabel="synchronous_commit"> 2684 <term><varname>synchronous_commit</varname> (<type>enum</type>) 2685 <indexterm> 2686 <primary><varname>synchronous_commit</varname> configuration parameter</primary> 2687 </indexterm> 2688 </term> 2689 <listitem> 2690 <para> 2691 Specifies how much WAL processing must complete before 2692 the database server returns a <quote>success</quote> 2693 indication to the client. Valid values are 2694 <literal>remote_apply</literal>, <literal>on</literal> 2695 (the default), <literal>remote_write</literal>, 2696 <literal>local</literal>, and <literal>off</literal>. 2697 </para> 2698 2699 <para> 2700 If <varname>synchronous_standby_names</varname> is empty, 2701 the only meaningful settings are <literal>on</literal> and 2702 <literal>off</literal>; <literal>remote_apply</literal>, 2703 <literal>remote_write</literal> and <literal>local</literal> 2704 all provide the same local synchronization level 2705 as <literal>on</literal>. The local behavior of all 2706 non-<literal>off</literal> modes is to wait for local flush of WAL 2707 to disk. In <literal>off</literal> mode, there is no waiting, 2708 so there can be a delay between when success is reported to the 2709 client and when the transaction is later guaranteed to be safe 2710 against a server crash. (The maximum 2711 delay is three times <xref linkend="guc-wal-writer-delay"/>.) Unlike 2712 <xref linkend="guc-fsync"/>, setting this parameter to <literal>off</literal> 2713 does not create any risk of database inconsistency: an operating 2714 system or database crash might 2715 result in some recent allegedly-committed transactions being lost, but 2716 the database state will be just the same as if those transactions had 2717 been aborted cleanly. So, turning <varname>synchronous_commit</varname> off 2718 can be a useful alternative when performance is more important than 2719 exact certainty about the durability of a transaction. For more 2720 discussion see <xref linkend="wal-async-commit"/>. 2721 </para> 2722 2723 <para> 2724 If <xref linkend="guc-synchronous-standby-names"/> is non-empty, 2725 <varname>synchronous_commit</varname> also controls whether 2726 transaction commits will wait for their WAL records to be 2727 processed on the standby server(s). 2728 </para> 2729 2730 <para> 2731 When set to <literal>remote_apply</literal>, commits will wait 2732 until replies from the current synchronous standby(s) indicate they 2733 have received the commit record of the transaction and applied 2734 it, so that it has become visible to queries on the standby(s), 2735 and also written to durable storage on the standbys. This will 2736 cause much larger commit delays than previous settings since 2737 it waits for WAL replay. When set to <literal>on</literal>, 2738 commits wait until replies 2739 from the current synchronous standby(s) indicate they have received 2740 the commit record of the transaction and flushed it to durable storage. This 2741 ensures the transaction will not be lost unless both the primary and 2742 all synchronous standbys suffer corruption of their database storage. 2743 When set to <literal>remote_write</literal>, commits will wait until replies 2744 from the current synchronous standby(s) indicate they have 2745 received the commit record of the transaction and written it to 2746 their file systems. This setting ensures data preservation if a standby instance of 2747 <productname>PostgreSQL</productname> crashes, but not if the standby 2748 suffers an operating-system-level crash because the data has not 2749 necessarily reached durable storage on the standby. 2750 The setting <literal>local</literal> causes commits to wait for 2751 local flush to disk, but not for replication. This is usually not 2752 desirable when synchronous replication is in use, but is provided for 2753 completeness. 2754 </para> 2755 2756 <para> 2757 This parameter can be changed at any time; the behavior for any 2758 one transaction is determined by the setting in effect when it 2759 commits. It is therefore possible, and useful, to have some 2760 transactions commit synchronously and others asynchronously. 2761 For example, to make a single multistatement transaction commit 2762 asynchronously when the default is the opposite, issue <command>SET 2763 LOCAL synchronous_commit TO OFF</command> within the transaction. 2764 </para> 2765 2766 <para> 2767 <xref linkend="synchronous-commit-matrix"/> summarizes the 2768 capabilities of the <varname>synchronous_commit</varname> settings. 2769 </para> 2770 2771 <table id="synchronous-commit-matrix"> 2772 <title>synchronous_commit Modes</title> 2773 <tgroup cols="5"> 2774 <colspec colname="col1" colwidth="1.5*"/> 2775 <colspec colname="col2" colwidth="1*"/> 2776 <colspec colname="col3" colwidth="1*"/> 2777 <colspec colname="col4" colwidth="1*"/> 2778 <colspec colname="col5" colwidth="1*"/> 2779 <thead> 2780 <row> 2781 <entry>synchronous_commit setting</entry> 2782 <entry>local durable commit</entry> 2783 <entry>standby durable commit after PG crash</entry> 2784 <entry>standby durable commit after OS crash</entry> 2785 <entry>standby query consistency</entry> 2786 </row> 2787 </thead> 2788 2789 <tbody> 2790 2791 <row> 2792 <entry>remote_apply</entry> 2793 <entry align="center">•</entry> 2794 <entry align="center">•</entry> 2795 <entry align="center">•</entry> 2796 <entry align="center">•</entry> 2797 </row> 2798 2799 <row> 2800 <entry>on</entry> 2801 <entry align="center">•</entry> 2802 <entry align="center">•</entry> 2803 <entry align="center">•</entry> 2804 <entry align="center"></entry> 2805 </row> 2806 2807 <row> 2808 <entry>remote_write</entry> 2809 <entry align="center">•</entry> 2810 <entry align="center">•</entry> 2811 <entry align="center"></entry> 2812 <entry align="center"></entry> 2813 </row> 2814 2815 <row> 2816 <entry>local</entry> 2817 <entry align="center">•</entry> 2818 <entry align="center"></entry> 2819 <entry align="center"></entry> 2820 <entry align="center"></entry> 2821 </row> 2822 2823 <row> 2824 <entry>off</entry> 2825 <entry align="center"></entry> 2826 <entry align="center"></entry> 2827 <entry align="center"></entry> 2828 <entry align="center"></entry> 2829 </row> 2830 2831 </tbody> 2832 </tgroup> 2833 </table> 2834 2835 </listitem> 2836 </varlistentry> 2837 2838 <varlistentry id="guc-wal-sync-method" xreflabel="wal_sync_method"> 2839 <term><varname>wal_sync_method</varname> (<type>enum</type>) 2840 <indexterm> 2841 <primary><varname>wal_sync_method</varname> configuration parameter</primary> 2842 </indexterm> 2843 </term> 2844 <listitem> 2845 <para> 2846 Method used for forcing WAL updates out to disk. 2847 If <varname>fsync</varname> is off then this setting is irrelevant, 2848 since WAL file updates will not be forced out at all. 2849 Possible values are: 2850 </para> 2851 <itemizedlist> 2852 <listitem> 2853 <para> 2854 <literal>open_datasync</literal> (write WAL files with <function>open()</function> option <symbol>O_DSYNC</symbol>) 2855 </para> 2856 </listitem> 2857 <listitem> 2858 <para> 2859 <literal>fdatasync</literal> (call <function>fdatasync()</function> at each commit) 2860 </para> 2861 </listitem> 2862 <listitem> 2863 <para> 2864 <literal>fsync</literal> (call <function>fsync()</function> at each commit) 2865 </para> 2866 </listitem> 2867 <listitem> 2868 <para> 2869 <literal>fsync_writethrough</literal> (call <function>fsync()</function> at each commit, forcing write-through of any disk write cache) 2870 </para> 2871 </listitem> 2872 <listitem> 2873 <para> 2874 <literal>open_sync</literal> (write WAL files with <function>open()</function> option <symbol>O_SYNC</symbol>) 2875 </para> 2876 </listitem> 2877 </itemizedlist> 2878 <para> 2879 The <literal>open_</literal>* options also use <literal>O_DIRECT</literal> if available. 2880 Not all of these choices are available on all platforms. 2881 The default is the first method in the above list that is supported 2882 by the platform, except that <literal>fdatasync</literal> is the default on 2883 Linux and FreeBSD. The default is not necessarily ideal; it might be 2884 necessary to change this setting or other aspects of your system 2885 configuration in order to create a crash-safe configuration or 2886 achieve optimal performance. 2887 These aspects are discussed in <xref linkend="wal-reliability"/>. 2888 This parameter can only be set in the <filename>postgresql.conf</filename> 2889 file or on the server command line. 2890 </para> 2891 </listitem> 2892 </varlistentry> 2893 2894 <varlistentry id="guc-full-page-writes" xreflabel="full_page_writes"> 2895 <term><varname>full_page_writes</varname> (<type>boolean</type>) 2896 <indexterm> 2897 <primary><varname>full_page_writes</varname> configuration parameter</primary> 2898 </indexterm> 2899 </term> 2900 <listitem> 2901 <para> 2902 When this parameter is on, the <productname>PostgreSQL</productname> server 2903 writes the entire content of each disk page to WAL during the 2904 first modification of that page after a checkpoint. 2905 This is needed because 2906 a page write that is in process during an operating system crash might 2907 be only partially completed, leading to an on-disk page 2908 that contains a mix of old and new data. The row-level change data 2909 normally stored in WAL will not be enough to completely restore 2910 such a page during post-crash recovery. Storing the full page image 2911 guarantees that the page can be correctly restored, but at the price 2912 of increasing the amount of data that must be written to WAL. 2913 (Because WAL replay always starts from a checkpoint, it is sufficient 2914 to do this during the first change of each page after a checkpoint. 2915 Therefore, one way to reduce the cost of full-page writes is to 2916 increase the checkpoint interval parameters.) 2917 </para> 2918 2919 <para> 2920 Turning this parameter off speeds normal operation, but 2921 might lead to either unrecoverable data corruption, or silent 2922 data corruption, after a system failure. The risks are similar to turning off 2923 <varname>fsync</varname>, though smaller, and it should be turned off 2924 only based on the same circumstances recommended for that parameter. 2925 </para> 2926 2927 <para> 2928 Turning off this parameter does not affect use of 2929 WAL archiving for point-in-time recovery (PITR) 2930 (see <xref linkend="continuous-archiving"/>). 2931 </para> 2932 2933 <para> 2934 This parameter can only be set in the <filename>postgresql.conf</filename> 2935 file or on the server command line. 2936 The default is <literal>on</literal>. 2937 </para> 2938 </listitem> 2939 </varlistentry> 2940 2941 <varlistentry id="guc-wal-log-hints" xreflabel="wal_log_hints"> 2942 <term><varname>wal_log_hints</varname> (<type>boolean</type>) 2943 <indexterm> 2944 <primary><varname>wal_log_hints</varname> configuration parameter</primary> 2945 </indexterm> 2946 </term> 2947 <listitem> 2948 <para> 2949 When this parameter is <literal>on</literal>, the <productname>PostgreSQL</productname> 2950 server writes the entire content of each disk page to WAL during the 2951 first modification of that page after a checkpoint, even for 2952 non-critical modifications of so-called hint bits. 2953 </para> 2954 2955 <para> 2956 If data checksums are enabled, hint bit updates are always WAL-logged 2957 and this setting is ignored. You can use this setting to test how much 2958 extra WAL-logging would occur if your database had data checksums 2959 enabled. 2960 </para> 2961 2962 <para> 2963 This parameter can only be set at server start. The default value is <literal>off</literal>. 2964 </para> 2965 </listitem> 2966 </varlistentry> 2967 2968 <varlistentry id="guc-wal-compression" xreflabel="wal_compression"> 2969 <term><varname>wal_compression</varname> (<type>boolean</type>) 2970 <indexterm> 2971 <primary><varname>wal_compression</varname> configuration parameter</primary> 2972 </indexterm> 2973 </term> 2974 <listitem> 2975 <para> 2976 When this parameter is <literal>on</literal>, the <productname>PostgreSQL</productname> 2977 server compresses a full page image written to WAL when 2978 <xref linkend="guc-full-page-writes"/> is on or during a base backup. 2979 A compressed page image will be decompressed during WAL replay. 2980 The default value is <literal>off</literal>. 2981 Only superusers can change this setting. 2982 </para> 2983 2984 <para> 2985 Turning this parameter on can reduce the WAL volume without 2986 increasing the risk of unrecoverable data corruption, 2987 but at the cost of some extra CPU spent on the compression during 2988 WAL logging and on the decompression during WAL replay. 2989 </para> 2990 </listitem> 2991 </varlistentry> 2992 2993 <varlistentry id="guc-wal-init-zero" xreflabel="wal_init_zero"> 2994 <term><varname>wal_init_zero</varname> (<type>boolean</type>) 2995 <indexterm> 2996 <primary><varname>wal_init_zero</varname> configuration parameter</primary> 2997 </indexterm> 2998 </term> 2999 <listitem> 3000 <para> 3001 If set to <literal>on</literal> (the default), this option causes new 3002 WAL files to be filled with zeroes. On some file systems, this ensures 3003 that space is allocated before we need to write WAL records. However, 3004 <firstterm>Copy-On-Write</firstterm> (COW) file systems may not benefit 3005 from this technique, so the option is given to skip the unnecessary 3006 work. If set to <literal>off</literal>, only the final byte is written 3007 when the file is created so that it has the expected size. 3008 </para> 3009 </listitem> 3010 </varlistentry> 3011 3012 <varlistentry id="guc-wal-recycle" xreflabel="wal_recycle"> 3013 <term><varname>wal_recycle</varname> (<type>boolean</type>) 3014 <indexterm> 3015 <primary><varname>wal_recycle</varname> configuration parameter</primary> 3016 </indexterm> 3017 </term> 3018 <listitem> 3019 <para> 3020 If set to <literal>on</literal> (the default), this option causes WAL 3021 files to be recycled by renaming them, avoiding the need to create new 3022 ones. On COW file systems, it may be faster to create new ones, so the 3023 option is given to disable this behavior. 3024 </para> 3025 </listitem> 3026 </varlistentry> 3027 3028 <varlistentry id="guc-wal-buffers" xreflabel="wal_buffers"> 3029 <term><varname>wal_buffers</varname> (<type>integer</type>) 3030 <indexterm> 3031 <primary><varname>wal_buffers</varname> configuration parameter</primary> 3032 </indexterm> 3033 </term> 3034 <listitem> 3035 <para> 3036 The amount of shared memory used for WAL data that has not yet been 3037 written to disk. The default setting of -1 selects a size equal to 3038 1/32nd (about 3%) of <xref linkend="guc-shared-buffers"/>, but not less 3039 than <literal>64kB</literal> nor more than the size of one WAL 3040 segment, typically <literal>16MB</literal>. This value can be set 3041 manually if the automatic choice is too large or too small, 3042 but any positive value less than <literal>32kB</literal> will be 3043 treated as <literal>32kB</literal>. 3044 If this value is specified without units, it is taken as WAL blocks, 3045 that is <symbol>XLOG_BLCKSZ</symbol> bytes, typically 8kB. 3046 This parameter can only be set at server start. 3047 </para> 3048 3049 <para> 3050 The contents of the WAL buffers are written out to disk at every 3051 transaction commit, so extremely large values are unlikely to 3052 provide a significant benefit. However, setting this value to at 3053 least a few megabytes can improve write performance on a busy 3054 server where many clients are committing at once. The auto-tuning 3055 selected by the default setting of -1 should give reasonable 3056 results in most cases. 3057 </para> 3058 3059 </listitem> 3060 </varlistentry> 3061 3062 <varlistentry id="guc-wal-writer-delay" xreflabel="wal_writer_delay"> 3063 <term><varname>wal_writer_delay</varname> (<type>integer</type>) 3064 <indexterm> 3065 <primary><varname>wal_writer_delay</varname> configuration parameter</primary> 3066 </indexterm> 3067 </term> 3068 <listitem> 3069 <para> 3070 Specifies how often the WAL writer flushes WAL, in time terms. 3071 After flushing WAL the writer sleeps for the length of time given 3072 by <varname>wal_writer_delay</varname>, unless woken up sooner 3073 by an asynchronously committing transaction. If the last flush 3074 happened less than <varname>wal_writer_delay</varname> ago and less 3075 than <varname>wal_writer_flush_after</varname> worth of WAL has been 3076 produced since, then WAL is only written to the operating system, not 3077 flushed to disk. 3078 If this value is specified without units, it is taken as milliseconds. 3079 The default value is 200 milliseconds (<literal>200ms</literal>). Note that 3080 on many systems, the effective resolution of sleep delays is 10 3081 milliseconds; setting <varname>wal_writer_delay</varname> to a value that is 3082 not a multiple of 10 might have the same results as setting it to the 3083 next higher multiple of 10. This parameter can only be set in the 3084 <filename>postgresql.conf</filename> file or on the server command line. 3085 </para> 3086 </listitem> 3087 </varlistentry> 3088 3089 <varlistentry id="guc-wal-writer-flush-after" xreflabel="wal_writer_flush_after"> 3090 <term><varname>wal_writer_flush_after</varname> (<type>integer</type>) 3091 <indexterm> 3092 <primary><varname>wal_writer_flush_after</varname> configuration parameter</primary> 3093 </indexterm> 3094 </term> 3095 <listitem> 3096 <para> 3097 Specifies how often the WAL writer flushes WAL, in volume terms. 3098 If the last flush happened less 3099 than <varname>wal_writer_delay</varname> ago and less 3100 than <varname>wal_writer_flush_after</varname> worth of WAL has been 3101 produced since, then WAL is only written to the operating system, not 3102 flushed to disk. If <varname>wal_writer_flush_after</varname> is set 3103 to <literal>0</literal> then WAL data is always flushed immediately. 3104 If this value is specified without units, it is taken as WAL blocks, 3105 that is <symbol>XLOG_BLCKSZ</symbol> bytes, typically 8kB. 3106 The default is <literal>1MB</literal>. 3107 This parameter can only be set in the 3108 <filename>postgresql.conf</filename> file or on the server command line. 3109 </para> 3110 </listitem> 3111 </varlistentry> 3112 3113 <varlistentry id="guc-wal-skip-threshold" xreflabel="wal_skip_threshold"> 3114 <term><varname>wal_skip_threshold</varname> (<type>integer</type>) 3115 <indexterm> 3116 <primary><varname>wal_skip_threshold</varname> configuration parameter</primary> 3117 </indexterm> 3118 </term> 3119 <listitem> 3120 <para> 3121 When <varname>wal_level</varname> is <literal>minimal</literal> and a 3122 transaction commits after creating or rewriting a permanent relation, 3123 this setting determines how to persist the new data. If the data is 3124 smaller than this setting, write it to the WAL log; otherwise, use an 3125 fsync of affected files. Depending on the properties of your storage, 3126 raising or lowering this value might help if such commits are slowing 3127 concurrent transactions. If this value is specified without units, it 3128 is taken as kilobytes. The default is two megabytes 3129 (<literal>2MB</literal>). 3130 </para> 3131 </listitem> 3132 </varlistentry> 3133 3134 <varlistentry id="guc-commit-delay" xreflabel="commit_delay"> 3135 <term><varname>commit_delay</varname> (<type>integer</type>) 3136 <indexterm> 3137 <primary><varname>commit_delay</varname> configuration parameter</primary> 3138 </indexterm> 3139 </term> 3140 <listitem> 3141 <para> 3142 Setting <varname>commit_delay</varname> adds a time delay 3143 before a WAL flush is initiated. This can improve 3144 group commit throughput by allowing a larger number of transactions 3145 to commit via a single WAL flush, if system load is high enough 3146 that additional transactions become ready to commit within the 3147 given interval. However, it also increases latency by up to the 3148 <varname>commit_delay</varname> for each WAL 3149 flush. Because the delay is just wasted if no other transactions 3150 become ready to commit, a delay is only performed if at least 3151 <varname>commit_siblings</varname> other transactions are active 3152 when a flush is about to be initiated. Also, no delays are 3153 performed if <varname>fsync</varname> is disabled. 3154 If this value is specified without units, it is taken as microseconds. 3155 The default <varname>commit_delay</varname> is zero (no delay). 3156 Only superusers can change this setting. 3157 </para> 3158 <para> 3159 In <productname>PostgreSQL</productname> releases prior to 9.3, 3160 <varname>commit_delay</varname> behaved differently and was much 3161 less effective: it affected only commits, rather than all WAL flushes, 3162 and waited for the entire configured delay even if the WAL flush 3163 was completed sooner. Beginning in <productname>PostgreSQL</productname> 9.3, 3164 the first process that becomes ready to flush waits for the configured 3165 interval, while subsequent processes wait only until the leader 3166 completes the flush operation. 3167 </para> 3168 </listitem> 3169 </varlistentry> 3170 3171 <varlistentry id="guc-commit-siblings" xreflabel="commit_siblings"> 3172 <term><varname>commit_siblings</varname> (<type>integer</type>) 3173 <indexterm> 3174 <primary><varname>commit_siblings</varname> configuration parameter</primary> 3175 </indexterm> 3176 </term> 3177 <listitem> 3178 <para> 3179 Minimum number of concurrent open transactions to require 3180 before performing the <varname>commit_delay</varname> delay. A larger 3181 value makes it more probable that at least one other 3182 transaction will become ready to commit during the delay 3183 interval. The default is five transactions. 3184 </para> 3185 </listitem> 3186 </varlistentry> 3187 3188 </variablelist> 3189 </sect2> 3190 <sect2 id="runtime-config-wal-checkpoints"> 3191 <title>Checkpoints</title> 3192 3193 <variablelist> 3194 <varlistentry id="guc-checkpoint-timeout" xreflabel="checkpoint_timeout"> 3195 <term><varname>checkpoint_timeout</varname> (<type>integer</type>) 3196 <indexterm> 3197 <primary><varname>checkpoint_timeout</varname> configuration parameter</primary> 3198 </indexterm> 3199 </term> 3200 <listitem> 3201 <para> 3202 Maximum time between automatic WAL checkpoints. 3203 If this value is specified without units, it is taken as seconds. 3204 The valid range is between 30 seconds and one day. 3205 The default is five minutes (<literal>5min</literal>). 3206 Increasing this parameter can increase the amount of time needed 3207 for crash recovery. 3208 This parameter can only be set in the <filename>postgresql.conf</filename> 3209 file or on the server command line. 3210 </para> 3211 </listitem> 3212 </varlistentry> 3213 3214 <varlistentry id="guc-checkpoint-completion-target" xreflabel="checkpoint_completion_target"> 3215 <term><varname>checkpoint_completion_target</varname> (<type>floating point</type>) 3216 <indexterm> 3217 <primary><varname>checkpoint_completion_target</varname> configuration parameter</primary> 3218 </indexterm> 3219 </term> 3220 <listitem> 3221 <para> 3222 Specifies the target of checkpoint completion, as a fraction of 3223 total time between checkpoints. The default is 0.5. 3224 This parameter can only be set in the <filename>postgresql.conf</filename> 3225 file or on the server command line. 3226 </para> 3227 </listitem> 3228 </varlistentry> 3229 3230 <varlistentry id="guc-checkpoint-flush-after" xreflabel="checkpoint_flush_after"> 3231 <term><varname>checkpoint_flush_after</varname> (<type>integer</type>) 3232 <indexterm> 3233 <primary><varname>checkpoint_flush_after</varname> configuration parameter</primary> 3234 </indexterm> 3235 </term> 3236 <listitem> 3237 <para> 3238 Whenever more than this amount of data has been 3239 written while performing a checkpoint, attempt to force the 3240 OS to issue these writes to the underlying storage. Doing so will 3241 limit the amount of dirty data in the kernel's page cache, reducing 3242 the likelihood of stalls when an <function>fsync</function> is issued at the end of the 3243 checkpoint, or when the OS writes data back in larger batches in the 3244 background. Often that will result in greatly reduced transaction 3245 latency, but there also are some cases, especially with workloads 3246 that are bigger than <xref linkend="guc-shared-buffers"/>, but smaller 3247 than the OS's page cache, where performance might degrade. This 3248 setting may have no effect on some platforms. 3249 If this value is specified without units, it is taken as blocks, 3250 that is <symbol>BLCKSZ</symbol> bytes, typically 8kB. 3251 The valid range is 3252 between <literal>0</literal>, which disables forced writeback, 3253 and <literal>2MB</literal>. The default is <literal>256kB</literal> on 3254 Linux, <literal>0</literal> elsewhere. (If <symbol>BLCKSZ</symbol> is not 3255 8kB, the default and maximum values scale proportionally to it.) 3256 This parameter can only be set in the <filename>postgresql.conf</filename> 3257 file or on the server command line. 3258 </para> 3259 </listitem> 3260 </varlistentry> 3261 3262 <varlistentry id="guc-checkpoint-warning" xreflabel="checkpoint_warning"> 3263 <term><varname>checkpoint_warning</varname> (<type>integer</type>) 3264 <indexterm> 3265 <primary><varname>checkpoint_warning</varname> configuration parameter</primary> 3266 </indexterm> 3267 </term> 3268 <listitem> 3269 <para> 3270 Write a message to the server log if checkpoints caused by 3271 the filling of WAL segment files happen closer together 3272 than this amount of time (which suggests that 3273 <varname>max_wal_size</varname> ought to be raised). 3274 If this value is specified without units, it is taken as seconds. 3275 The default is 30 seconds (<literal>30s</literal>). 3276 Zero disables the warning. 3277 No warnings will be generated if <varname>checkpoint_timeout</varname> 3278 is less than <varname>checkpoint_warning</varname>. 3279 This parameter can only be set in the <filename>postgresql.conf</filename> 3280 file or on the server command line. 3281 </para> 3282 </listitem> 3283 </varlistentry> 3284 3285 <varlistentry id="guc-max-wal-size" xreflabel="max_wal_size"> 3286 <term><varname>max_wal_size</varname> (<type>integer</type>) 3287 <indexterm> 3288 <primary><varname>max_wal_size</varname> configuration parameter</primary> 3289 </indexterm> 3290 </term> 3291 <listitem> 3292 <para> 3293 Maximum size to let the WAL grow during automatic 3294 checkpoints. This is a soft limit; WAL size can exceed 3295 <varname>max_wal_size</varname> under special circumstances, such as 3296 heavy load, a failing <varname>archive_command</varname>, or a high 3297 <varname>wal_keep_size</varname> setting. 3298 If this value is specified without units, it is taken as megabytes. 3299 The default is 1 GB. 3300 Increasing this parameter can increase the amount of time needed for 3301 crash recovery. 3302 This parameter can only be set in the <filename>postgresql.conf</filename> 3303 file or on the server command line. 3304 </para> 3305 </listitem> 3306 </varlistentry> 3307 3308 <varlistentry id="guc-min-wal-size" xreflabel="min_wal_size"> 3309 <term><varname>min_wal_size</varname> (<type>integer</type>) 3310 <indexterm> 3311 <primary><varname>min_wal_size</varname> configuration parameter</primary> 3312 </indexterm> 3313 </term> 3314 <listitem> 3315 <para> 3316 As long as WAL disk usage stays below this setting, old WAL files are 3317 always recycled for future use at a checkpoint, rather than removed. 3318 This can be used to ensure that enough WAL space is reserved to 3319 handle spikes in WAL usage, for example when running large batch 3320 jobs. 3321 If this value is specified without units, it is taken as megabytes. 3322 The default is 80 MB. 3323 This parameter can only be set in the <filename>postgresql.conf</filename> 3324 file or on the server command line. 3325 </para> 3326 </listitem> 3327 </varlistentry> 3328 3329 </variablelist> 3330 </sect2> 3331 <sect2 id="runtime-config-wal-archiving"> 3332 <title>Archiving</title> 3333 3334 <variablelist> 3335 <varlistentry id="guc-archive-mode" xreflabel="archive_mode"> 3336 <term><varname>archive_mode</varname> (<type>enum</type>) 3337 <indexterm> 3338 <primary><varname>archive_mode</varname> configuration parameter</primary> 3339 </indexterm> 3340 </term> 3341 <listitem> 3342 <para> 3343 When <varname>archive_mode</varname> is enabled, completed WAL segments 3344 are sent to archive storage by setting 3345 <xref linkend="guc-archive-command"/>. In addition to <literal>off</literal>, 3346 to disable, there are two modes: <literal>on</literal>, and 3347 <literal>always</literal>. During normal operation, there is no 3348 difference between the two modes, but when set to <literal>always</literal> 3349 the WAL archiver is enabled also during archive recovery or standby 3350 mode. In <literal>always</literal> mode, all files restored from the archive 3351 or streamed with streaming replication will be archived (again). See 3352 <xref linkend="continuous-archiving-in-standby"/> for details. 3353 </para> 3354 <para> 3355 <varname>archive_mode</varname> and <varname>archive_command</varname> are 3356 separate variables so that <varname>archive_command</varname> can be 3357 changed without leaving archiving mode. 3358 This parameter can only be set at server start. 3359 <varname>archive_mode</varname> cannot be enabled when 3360 <varname>wal_level</varname> is set to <literal>minimal</literal>. 3361 </para> 3362 </listitem> 3363 </varlistentry> 3364 3365 <varlistentry id="guc-archive-command" xreflabel="archive_command"> 3366 <term><varname>archive_command</varname> (<type>string</type>) 3367 <indexterm> 3368 <primary><varname>archive_command</varname> configuration parameter</primary> 3369 </indexterm> 3370 </term> 3371 <listitem> 3372 <para> 3373 The local shell command to execute to archive a completed WAL file 3374 segment. Any <literal>%p</literal> in the string is 3375 replaced by the path name of the file to archive, and any 3376 <literal>%f</literal> is replaced by only the file name. 3377 (The path name is relative to the working directory of the server, 3378 i.e., the cluster's data directory.) 3379 Use <literal>%%</literal> to embed an actual <literal>%</literal> character in the 3380 command. It is important for the command to return a zero 3381 exit status only if it succeeds. For more information see 3382 <xref linkend="backup-archiving-wal"/>. 3383 </para> 3384 <para> 3385 This parameter can only be set in the <filename>postgresql.conf</filename> 3386 file or on the server command line. It is ignored unless 3387 <varname>archive_mode</varname> was enabled at server start. 3388 If <varname>archive_command</varname> is an empty string (the default) while 3389 <varname>archive_mode</varname> is enabled, WAL archiving is temporarily 3390 disabled, but the server continues to accumulate WAL segment files in 3391 the expectation that a command will soon be provided. Setting 3392 <varname>archive_command</varname> to a command that does nothing but 3393 return true, e.g., <literal>/bin/true</literal> (<literal>REM</literal> on 3394 Windows), effectively disables 3395 archiving, but also breaks the chain of WAL files needed for 3396 archive recovery, so it should only be used in unusual circumstances. 3397 </para> 3398 </listitem> 3399 </varlistentry> 3400 3401 <varlistentry id="guc-archive-timeout" xreflabel="archive_timeout"> 3402 <term><varname>archive_timeout</varname> (<type>integer</type>) 3403 <indexterm> 3404 <primary><varname>archive_timeout</varname> configuration parameter</primary> 3405 </indexterm> 3406 </term> 3407 <listitem> 3408 <para> 3409 The <xref linkend="guc-archive-command"/> is only invoked for 3410 completed WAL segments. Hence, if your server generates little WAL 3411 traffic (or has slack periods where it does so), there could be a 3412 long delay between the completion of a transaction and its safe 3413 recording in archive storage. To limit how old unarchived 3414 data can be, you can set <varname>archive_timeout</varname> to force the 3415 server to switch to a new WAL segment file periodically. When this 3416 parameter is greater than zero, the server will switch to a new 3417 segment file whenever this amount of time has elapsed since the last 3418 segment file switch, and there has been any database activity, 3419 including a single checkpoint (checkpoints are skipped if there is 3420 no database activity). Note that archived files that are closed 3421 early due to a forced switch are still the same length as completely 3422 full files. Therefore, it is unwise to use a very short 3423 <varname>archive_timeout</varname> — it will bloat your archive 3424 storage. <varname>archive_timeout</varname> settings of a minute or so are 3425 usually reasonable. You should consider using streaming replication, 3426 instead of archiving, if you want data to be copied off the master 3427 server more quickly than that. 3428 If this value is specified without units, it is taken as seconds. 3429 This parameter can only be set in the 3430 <filename>postgresql.conf</filename> file or on the server command line. 3431 </para> 3432 </listitem> 3433 </varlistentry> 3434 3435 </variablelist> 3436 </sect2> 3437 3438 <sect2 id="runtime-config-wal-archive-recovery"> 3439 3440 <title>Archive Recovery</title> 3441 3442 <indexterm> 3443 <primary>configuration</primary> 3444 <secondary>of recovery</secondary> 3445 <tertiary>of a standby server</tertiary> 3446 </indexterm> 3447 3448 <para> 3449 This section describes the settings that apply only for the duration of 3450 the recovery. They must be reset for any subsequent recovery you wish to 3451 perform. 3452 </para> 3453 3454 <para> 3455 <quote>Recovery</quote> covers using the server as a standby or for 3456 executing a targeted recovery. Typically, standby mode would be used to 3457 provide high availability and/or read scalability, whereas a targeted 3458 recovery is used to recover from data loss. 3459 </para> 3460 3461 <para> 3462 To start the server in standby mode, create a file called 3463 <filename>standby.signal</filename><indexterm><primary>standby.signal</primary></indexterm> 3464 in the data directory. The server will enter recovery and will not stop 3465 recovery when the end of archived WAL is reached, but will keep trying to 3466 continue recovery by connecting to the sending server as specified by the 3467 <varname>primary_conninfo</varname> setting and/or by fetching new WAL 3468 segments using <varname>restore_command</varname>. For this mode, the 3469 parameters from this section and <xref 3470 linkend="runtime-config-replication-standby"/> are of interest. 3471 Parameters from <xref linkend="runtime-config-wal-recovery-target"/> will 3472 also be applied but are typically not useful in this mode. 3473 </para> 3474 3475 <para> 3476 To start the server in targeted recovery mode, create a file called 3477 <filename>recovery.signal</filename><indexterm><primary>recovery.signal</primary></indexterm> 3478 in the data directory. If both <filename>standby.signal</filename> and 3479 <filename>recovery.signal</filename> files are created, standby mode 3480 takes precedence. Targeted recovery mode ends when the archived WAL is 3481 fully replayed, or when <varname>recovery_target</varname> is reached. 3482 In this mode, the parameters from both this section and <xref 3483 linkend="runtime-config-wal-recovery-target"/> will be used. 3484 </para> 3485 3486 <variablelist> 3487 <varlistentry id="guc-restore-command" xreflabel="restore_command"> 3488 <term><varname>restore_command</varname> (<type>string</type>) 3489 <indexterm> 3490 <primary><varname>restore_command</varname> configuration parameter</primary> 3491 </indexterm> 3492 </term> 3493 <listitem> 3494 <para> 3495 The local shell command to execute to retrieve an archived segment of 3496 the WAL file series. This parameter is required for archive recovery, 3497 but optional for streaming replication. 3498 Any <literal>%f</literal> in the string is 3499 replaced by the name of the file to retrieve from the archive, 3500 and any <literal>%p</literal> is replaced by the copy destination path name 3501 on the server. 3502 (The path name is relative to the current working directory, 3503 i.e., the cluster's data directory.) 3504 Any <literal>%r</literal> is replaced by the name of the file containing the 3505 last valid restart point. That is the earliest file that must be kept 3506 to allow a restore to be restartable, so this information can be used 3507 to truncate the archive to just the minimum required to support 3508 restarting from the current restore. <literal>%r</literal> is typically only 3509 used by warm-standby configurations 3510 (see <xref linkend="warm-standby"/>). 3511 Write <literal>%%</literal> to embed an actual <literal>%</literal> character. 3512 </para> 3513 3514 <para> 3515 It is important for the command to return a zero exit status 3516 only if it succeeds. The command <emphasis>will</emphasis> be asked for file 3517 names that are not present in the archive; it must return nonzero 3518 when so asked. Examples: 3519<programlisting> 3520restore_command = 'cp /mnt/server/archivedir/%f "%p"' 3521restore_command = 'copy "C:\\server\\archivedir\\%f" "%p"' # Windows 3522</programlisting> 3523 An exception is that if the command was terminated by a signal (other 3524 than <systemitem>SIGTERM</systemitem>, which is used as part of a 3525 database server shutdown) or an error by the shell (such as command 3526 not found), then recovery will abort and the server will not start up. 3527 </para> 3528 3529 <para> 3530 This parameter can only be set at server start. 3531 </para> 3532 </listitem> 3533 </varlistentry> 3534 3535 <varlistentry id="guc-archive-cleanup-command" xreflabel="archive_cleanup_command"> 3536 <term><varname>archive_cleanup_command</varname> (<type>string</type>) 3537 <indexterm> 3538 <primary><varname>archive_cleanup_command</varname> configuration parameter</primary> 3539 </indexterm> 3540 </term> 3541 <listitem> 3542 <para> 3543 This optional parameter specifies a shell command that will be executed 3544 at every restartpoint. The purpose of 3545 <varname>archive_cleanup_command</varname> is to provide a mechanism for 3546 cleaning up old archived WAL files that are no longer needed by the 3547 standby server. 3548 Any <literal>%r</literal> is replaced by the name of the file containing the 3549 last valid restart point. 3550 That is the earliest file that must be <emphasis>kept</emphasis> to allow a 3551 restore to be restartable, and so all files earlier than <literal>%r</literal> 3552 may be safely removed. 3553 This information can be used to truncate the archive to just the 3554 minimum required to support restart from the current restore. 3555 The <xref linkend="pgarchivecleanup"/> module 3556 is often used in <varname>archive_cleanup_command</varname> for 3557 single-standby configurations, for example: 3558<programlisting>archive_cleanup_command = 'pg_archivecleanup /mnt/server/archivedir %r'</programlisting> 3559 Note however that if multiple standby servers are restoring from the 3560 same archive directory, you will need to ensure that you do not delete 3561 WAL files until they are no longer needed by any of the servers. 3562 <varname>archive_cleanup_command</varname> would typically be used in a 3563 warm-standby configuration (see <xref linkend="warm-standby"/>). 3564 Write <literal>%%</literal> to embed an actual <literal>%</literal> character in the 3565 command. 3566 </para> 3567 <para> 3568 If the command returns a nonzero exit status then a warning log 3569 message will be written. An exception is that if the command was 3570 terminated by a signal or an error by the shell (such as command not 3571 found), a fatal error will be raised. 3572 </para> 3573 <para> 3574 This parameter can only be set in the <filename>postgresql.conf</filename> 3575 file or on the server command line. 3576 </para> 3577 </listitem> 3578 </varlistentry> 3579 3580 <varlistentry id="guc-recovery-end-command" xreflabel="recovery_end_command"> 3581 <term><varname>recovery_end_command</varname> (<type>string</type>) 3582 <indexterm> 3583 <primary><varname>recovery_end_command</varname> configuration parameter</primary> 3584 </indexterm> 3585 </term> 3586 <listitem> 3587 <para> 3588 This parameter specifies a shell command that will be executed once only 3589 at the end of recovery. This parameter is optional. The purpose of the 3590 <varname>recovery_end_command</varname> is to provide a mechanism for cleanup 3591 following replication or recovery. 3592 Any <literal>%r</literal> is replaced by the name of the file containing the 3593 last valid restart point, like in <xref linkend="guc-archive-cleanup-command"/>. 3594 </para> 3595 <para> 3596 If the command returns a nonzero exit status then a warning log 3597 message will be written and the database will proceed to start up 3598 anyway. An exception is that if the command was terminated by a 3599 signal or an error by the shell (such as command not found), the 3600 database will not proceed with startup. 3601 </para> 3602 <para> 3603 This parameter can only be set in the <filename>postgresql.conf</filename> 3604 file or on the server command line. 3605 </para> 3606 </listitem> 3607 </varlistentry> 3608 3609 </variablelist> 3610 3611 </sect2> 3612 3613 <sect2 id="runtime-config-wal-recovery-target"> 3614 3615 <title>Recovery Target</title> 3616 3617 <para> 3618 By default, recovery will recover to the end of the WAL log. The 3619 following parameters can be used to specify an earlier stopping point. 3620 At most one of <varname>recovery_target</varname>, 3621 <varname>recovery_target_lsn</varname>, <varname>recovery_target_name</varname>, 3622 <varname>recovery_target_time</varname>, or <varname>recovery_target_xid</varname> 3623 can be used; if more than one of these is specified in the configuration 3624 file, an error will be raised. 3625 These parameters can only be set at server start. 3626 </para> 3627 3628 <variablelist> 3629 <varlistentry id="guc-recovery-target" xreflabel="recovery_target"> 3630 <term><varname>recovery_target</varname><literal> = 'immediate'</literal> 3631 <indexterm> 3632 <primary><varname>recovery_target</varname> configuration parameter</primary> 3633 </indexterm> 3634 </term> 3635 <listitem> 3636 <para> 3637 This parameter specifies that recovery should end as soon as a 3638 consistent state is reached, i.e., as early as possible. When restoring 3639 from an online backup, this means the point where taking the backup 3640 ended. 3641 </para> 3642 <para> 3643 Technically, this is a string parameter, but <literal>'immediate'</literal> 3644 is currently the only allowed value. 3645 </para> 3646 </listitem> 3647 </varlistentry> 3648 3649 <varlistentry id="guc-recovery-target-name" xreflabel="recovery_target_name"> 3650 <term><varname>recovery_target_name</varname> (<type>string</type>) 3651 <indexterm> 3652 <primary><varname>recovery_target_name</varname> configuration parameter</primary> 3653 </indexterm> 3654 </term> 3655 <listitem> 3656 <para> 3657 This parameter specifies the named restore point (created with 3658 <function>pg_create_restore_point()</function>) to which recovery will proceed. 3659 </para> 3660 </listitem> 3661 </varlistentry> 3662 3663 <varlistentry id="guc-recovery-target-time" xreflabel="recovery_target_time"> 3664 <term><varname>recovery_target_time</varname> (<type>timestamp</type>) 3665 <indexterm> 3666 <primary><varname>recovery_target_time</varname> configuration parameter</primary> 3667 </indexterm> 3668 </term> 3669 <listitem> 3670 <para> 3671 This parameter specifies the time stamp up to which recovery 3672 will proceed. 3673 The precise stopping point is also influenced by 3674 <xref linkend="guc-recovery-target-inclusive"/>. 3675 </para> 3676 3677 <para> 3678 The value of this parameter is a time stamp in the same format 3679 accepted by the <type>timestamp with time zone</type> data type, 3680 except that you cannot use a time zone abbreviation (unless the 3681 <xref linkend="guc-timezone-abbreviations"/> variable has been set 3682 earlier in the configuration file). Preferred style is to use a 3683 numeric offset from UTC, or you can write a full time zone name, 3684 e.g., <literal>Europe/Helsinki</literal> not <literal>EEST</literal>. 3685 </para> 3686 </listitem> 3687 </varlistentry> 3688 3689 <varlistentry id="guc-recovery-target-xid" xreflabel="recovery_target_xid"> 3690 <term><varname>recovery_target_xid</varname> (<type>string</type>) 3691 <indexterm> 3692 <primary><varname>recovery_target_xid</varname> configuration parameter</primary> 3693 </indexterm> 3694 </term> 3695 <listitem> 3696 <para> 3697 This parameter specifies the transaction ID up to which recovery 3698 will proceed. Keep in mind 3699 that while transaction IDs are assigned sequentially at transaction 3700 start, transactions can complete in a different numeric order. 3701 The transactions that will be recovered are those that committed 3702 before (and optionally including) the specified one. 3703 The precise stopping point is also influenced by 3704 <xref linkend="guc-recovery-target-inclusive"/>. 3705 </para> 3706 </listitem> 3707 </varlistentry> 3708 3709 <varlistentry id="guc-recovery-target-lsn" xreflabel="recovery_target_lsn"> 3710 <term><varname>recovery_target_lsn</varname> (<type>pg_lsn</type>) 3711 <indexterm> 3712 <primary><varname>recovery_target_lsn</varname> configuration parameter</primary> 3713 </indexterm> 3714 </term> 3715 <listitem> 3716 <para> 3717 This parameter specifies the LSN of the write-ahead log location up 3718 to which recovery will proceed. The precise stopping point is also 3719 influenced by <xref linkend="guc-recovery-target-inclusive"/>. This 3720 parameter is parsed using the system data type 3721 <link linkend="datatype-pg-lsn"><type>pg_lsn</type></link>. 3722 </para> 3723 </listitem> 3724 </varlistentry> 3725 </variablelist> 3726 3727 <para> 3728 The following options further specify the recovery target, and affect 3729 what happens when the target is reached: 3730 </para> 3731 3732 <variablelist> 3733 <varlistentry id="guc-recovery-target-inclusive" 3734 xreflabel="recovery_target_inclusive"> 3735 <term><varname>recovery_target_inclusive</varname> (<type>boolean</type>) 3736 <indexterm> 3737 <primary><varname>recovery_target_inclusive</varname> configuration parameter</primary> 3738 </indexterm> 3739 </term> 3740 <listitem> 3741 <para> 3742 Specifies whether to stop just after the specified recovery target 3743 (<literal>on</literal>), or just before the recovery target 3744 (<literal>off</literal>). 3745 Applies when <xref linkend="guc-recovery-target-lsn"/>, 3746 <xref linkend="guc-recovery-target-time"/>, or 3747 <xref linkend="guc-recovery-target-xid"/> is specified. 3748 This setting controls whether transactions 3749 having exactly the target WAL location (LSN), commit time, or transaction ID, respectively, will 3750 be included in the recovery. Default is <literal>on</literal>. 3751 </para> 3752 </listitem> 3753 </varlistentry> 3754 3755 <varlistentry id="guc-recovery-target-timeline" 3756 xreflabel="recovery_target_timeline"> 3757 <term><varname>recovery_target_timeline</varname> (<type>string</type>) 3758 <indexterm> 3759 <primary><varname>recovery_target_timeline</varname> configuration parameter</primary> 3760 </indexterm> 3761 </term> 3762 <listitem> 3763 <para> 3764 Specifies recovering into a particular timeline. The value can be a 3765 numeric timeline ID or a special value. The value 3766 <literal>current</literal> recovers along the same timeline that was 3767 current when the base backup was taken. The 3768 value <literal>latest</literal> recovers 3769 to the latest timeline found in the archive, which is useful in 3770 a standby server. <literal>latest</literal> is the default. 3771 </para> 3772 3773 <para> 3774 You usually only need to set this parameter 3775 in complex re-recovery situations, where you need to return to 3776 a state that itself was reached after a point-in-time recovery. 3777 See <xref linkend="backup-timelines"/> for discussion. 3778 </para> 3779 </listitem> 3780 </varlistentry> 3781 3782 <varlistentry id="guc-recovery-target-action" 3783 xreflabel="recovery_target_action"> 3784 <term><varname>recovery_target_action</varname> (<type>enum</type>) 3785 <indexterm> 3786 <primary><varname>recovery_target_action</varname> configuration parameter</primary> 3787 </indexterm> 3788 </term> 3789 <listitem> 3790 <para> 3791 Specifies what action the server should take once the recovery target is 3792 reached. The default is <literal>pause</literal>, which means recovery will 3793 be paused. <literal>promote</literal> means the recovery process will finish 3794 and the server will start to accept connections. 3795 Finally <literal>shutdown</literal> will stop the server after reaching the 3796 recovery target. 3797 </para> 3798 <para> 3799 The intended use of the <literal>pause</literal> setting is to allow queries 3800 to be executed against the database to check if this recovery target 3801 is the most desirable point for recovery. 3802 The paused state can be resumed by 3803 using <function>pg_wal_replay_resume()</function> (see 3804 <xref linkend="functions-recovery-control-table"/>), which then 3805 causes recovery to end. If this recovery target is not the 3806 desired stopping point, then shut down the server, change the 3807 recovery target settings to a later target and restart to 3808 continue recovery. 3809 </para> 3810 <para> 3811 The <literal>shutdown</literal> setting is useful to have the instance ready 3812 at the exact replay point desired. The instance will still be able to 3813 replay more WAL records (and in fact will have to replay WAL records 3814 since the last checkpoint next time it is started). 3815 </para> 3816 <para> 3817 Note that because <filename>recovery.signal</filename> will not be 3818 removed when <varname>recovery_target_action</varname> is set to <literal>shutdown</literal>, 3819 any subsequent start will end with immediate shutdown unless the 3820 configuration is changed or the <filename>recovery.signal</filename> 3821 file is removed manually. 3822 </para> 3823 <para> 3824 This setting has no effect if no recovery target is set. 3825 If <xref linkend="guc-hot-standby"/> is not enabled, a setting of 3826 <literal>pause</literal> will act the same as <literal>shutdown</literal>. 3827 If the recovery target is reached while a promotion is ongoing, 3828 a setting of <literal>pause</literal> will act the same as 3829 <literal>promote</literal>. 3830 </para> 3831 <para> 3832 In any case, if a recovery target is configured but the archive 3833 recovery ends before the target is reached, the server will shut down 3834 with a fatal error. 3835 </para> 3836 </listitem> 3837 </varlistentry> 3838 3839 </variablelist> 3840 </sect2> 3841 3842 </sect1> 3843 3844 <sect1 id="runtime-config-replication"> 3845 <title>Replication</title> 3846 3847 <para> 3848 These settings control the behavior of the built-in 3849 <firstterm>streaming replication</firstterm> feature (see 3850 <xref linkend="streaming-replication"/>). Servers will be either a 3851 master or a standby server. Masters can send data, while standbys 3852 are always receivers of replicated data. When cascading replication 3853 (see <xref linkend="cascading-replication"/>) is used, standby servers 3854 can also be senders, as well as receivers. 3855 Parameters are mainly for sending and standby servers, though some 3856 parameters have meaning only on the master server. Settings may vary 3857 across the cluster without problems if that is required. 3858 </para> 3859 3860 <sect2 id="runtime-config-replication-sender"> 3861 <title>Sending Servers</title> 3862 3863 <para> 3864 These parameters can be set on any server that is 3865 to send replication data to one or more standby servers. 3866 The master is always a sending server, so these parameters must 3867 always be set on the master. 3868 The role and meaning of these parameters does not change after a 3869 standby becomes the master. 3870 </para> 3871 3872 <variablelist> 3873 <varlistentry id="guc-max-wal-senders" xreflabel="max_wal_senders"> 3874 <term><varname>max_wal_senders</varname> (<type>integer</type>) 3875 <indexterm> 3876 <primary><varname>max_wal_senders</varname> configuration parameter</primary> 3877 </indexterm> 3878 </term> 3879 <listitem> 3880 <para> 3881 Specifies the maximum number of concurrent connections from standby 3882 servers or streaming base backup clients (i.e., the maximum number of 3883 simultaneously running WAL sender processes). The default is 3884 <literal>10</literal>. The value <literal>0</literal> means 3885 replication is disabled. Abrupt disconnection of a streaming client might 3886 leave an orphaned connection slot behind until a timeout is reached, 3887 so this parameter should be set slightly higher than the maximum 3888 number of expected clients so disconnected clients can immediately 3889 reconnect. This parameter can only be set at server start. Also, 3890 <varname>wal_level</varname> must be set to 3891 <literal>replica</literal> or higher to allow connections from standby 3892 servers. 3893 </para> 3894 3895 <para> 3896 When running a standby server, you must set this parameter to the 3897 same or higher value than on the master server. Otherwise, queries 3898 will not be allowed in the standby server. 3899 </para> 3900 </listitem> 3901 </varlistentry> 3902 3903 <varlistentry id="guc-max-replication-slots" xreflabel="max_replication_slots"> 3904 <term><varname>max_replication_slots</varname> (<type>integer</type>) 3905 <indexterm> 3906 <primary><varname>max_replication_slots</varname> configuration parameter</primary> 3907 </indexterm> 3908 </term> 3909 <listitem> 3910 <para> 3911 Specifies the maximum number of replication slots 3912 (see <xref linkend="streaming-replication-slots"/>) that the server 3913 can support. The default is 10. This parameter can only be set at 3914 server start. 3915 Setting it to a lower value than the number of currently 3916 existing replication slots will prevent the server from starting. 3917 Also, <varname>wal_level</varname> must be set 3918 to <literal>replica</literal> or higher to allow replication slots to 3919 be used. 3920 </para> 3921 3922 <para> 3923 On the subscriber side, specifies how many replication origins (see 3924 <xref linkend="replication-origins"/>) can be tracked simultaneously, 3925 effectively limiting how many logical replication subscriptions can 3926 be created on the server. Setting it a lower value than the current 3927 number of tracked replication origins (reflected in 3928 <link linkend="view-pg-replication-origin-status">pg_replication_origin_status</link>, 3929 not <link linkend="catalog-pg-replication-origin">pg_replication_origin</link>) 3930 will prevent the server from starting. 3931 </para> 3932 </listitem> 3933 </varlistentry> 3934 3935 <varlistentry id="guc-wal-keep-size" xreflabel="wal_keep_size"> 3936 <term><varname>wal_keep_size</varname> (<type>integer</type>) 3937 <indexterm> 3938 <primary><varname>wal_keep_size</varname> configuration parameter</primary> 3939 </indexterm> 3940 </term> 3941 <listitem> 3942 <para> 3943 Specifies the minimum size of past log file segments kept in the 3944 <filename>pg_wal</filename> 3945 directory, in case a standby server needs to fetch them for streaming 3946 replication. If a standby 3947 server connected to the sending server falls behind by more than 3948 <varname>wal_keep_size</varname> megabytes, the sending server might 3949 remove a WAL segment still needed by the standby, in which case the 3950 replication connection will be terminated. Downstream connections 3951 will also eventually fail as a result. (However, the standby 3952 server can recover by fetching the segment from archive, if WAL 3953 archiving is in use.) 3954 </para> 3955 3956 <para> 3957 This sets only the minimum size of segments retained in 3958 <filename>pg_wal</filename>; the system might need to retain more segments 3959 for WAL archival or to recover from a checkpoint. If 3960 <varname>wal_keep_size</varname> is zero (the default), the system 3961 doesn't keep any extra segments for standby purposes, so the number 3962 of old WAL segments available to standby servers is a function of 3963 the location of the previous checkpoint and status of WAL 3964 archiving. 3965 If this value is specified without units, it is taken as megabytes. 3966 This parameter can only be set in the 3967 <filename>postgresql.conf</filename> file or on the server command line. 3968 </para> 3969 </listitem> 3970 </varlistentry> 3971 3972 <varlistentry id="guc-max-slot-wal-keep-size" xreflabel="max_slot_wal_keep_size"> 3973 <term><varname>max_slot_wal_keep_size</varname> (<type>integer</type>) 3974 <indexterm> 3975 <primary><varname>max_slot_wal_keep_size</varname> configuration parameter</primary> 3976 </indexterm> 3977 </term> 3978 <listitem> 3979 <para> 3980 Specify the maximum size of WAL files 3981 that <link linkend="streaming-replication-slots">replication 3982 slots</link> are allowed to retain in the <filename>pg_wal</filename> 3983 directory at checkpoint time. 3984 If <varname>max_slot_wal_keep_size</varname> is -1 (the default), 3985 replication slots may retain an unlimited amount of WAL files. Otherwise, if 3986 restart_lsn of a replication slot falls behind the current LSN by more 3987 than the given size, the standby using the slot may no longer be able 3988 to continue replication due to removal of required WAL files. You 3989 can see the WAL availability of replication slots 3990 in <link linkend="view-pg-replication-slots">pg_replication_slots</link>. 3991 </para> 3992 </listitem> 3993 </varlistentry> 3994 3995 <varlistentry id="guc-wal-sender-timeout" xreflabel="wal_sender_timeout"> 3996 <term><varname>wal_sender_timeout</varname> (<type>integer</type>) 3997 <indexterm> 3998 <primary><varname>wal_sender_timeout</varname> configuration parameter</primary> 3999 </indexterm> 4000 </term> 4001 <listitem> 4002 <para> 4003 Terminate replication connections that are inactive for longer 4004 than this amount of time. This is useful for 4005 the sending server to detect a standby crash or network outage. 4006 If this value is specified without units, it is taken as milliseconds. 4007 The default value is 60 seconds. 4008 A value of zero disables the timeout mechanism. 4009 </para> 4010 <para> 4011 With a cluster distributed across multiple geographic 4012 locations, using different values per location brings more flexibility 4013 in the cluster management. A smaller value is useful for faster 4014 failure detection with a standby having a low-latency network 4015 connection, and a larger value helps in judging better the health 4016 of a standby if located on a remote location, with a high-latency 4017 network connection. 4018 </para> 4019 </listitem> 4020 </varlistentry> 4021 4022 <varlistentry id="guc-track-commit-timestamp" xreflabel="track_commit_timestamp"> 4023 <term><varname>track_commit_timestamp</varname> (<type>boolean</type>) 4024 <indexterm> 4025 <primary><varname>track_commit_timestamp</varname> configuration parameter</primary> 4026 </indexterm> 4027 </term> 4028 <listitem> 4029 <para> 4030 Record commit time of transactions. This parameter 4031 can only be set in <filename>postgresql.conf</filename> file or on the server 4032 command line. The default value is <literal>off</literal>. 4033 </para> 4034 </listitem> 4035 </varlistentry> 4036 4037 </variablelist> 4038 </sect2> 4039 4040 <sect2 id="runtime-config-replication-master"> 4041 <title>Master Server</title> 4042 4043 <para> 4044 These parameters can be set on the master/primary server that is 4045 to send replication data to one or more standby servers. 4046 Note that in addition to these parameters, 4047 <xref linkend="guc-wal-level"/> must be set appropriately on the master 4048 server, and optionally WAL archiving can be enabled as 4049 well (see <xref linkend="runtime-config-wal-archiving"/>). 4050 The values of these parameters on standby servers are irrelevant, 4051 although you may wish to set them there in preparation for the 4052 possibility of a standby becoming the master. 4053 </para> 4054 4055 <variablelist> 4056 4057 <varlistentry id="guc-synchronous-standby-names" xreflabel="synchronous_standby_names"> 4058 <term><varname>synchronous_standby_names</varname> (<type>string</type>) 4059 <indexterm> 4060 <primary><varname>synchronous_standby_names</varname> configuration parameter</primary> 4061 </indexterm> 4062 </term> 4063 <listitem> 4064 <para> 4065 Specifies a list of standby servers that can support 4066 <firstterm>synchronous replication</firstterm>, as described in 4067 <xref linkend="synchronous-replication"/>. 4068 There will be one or more active synchronous standbys; 4069 transactions waiting for commit will be allowed to proceed after 4070 these standby servers confirm receipt of their data. 4071 The synchronous standbys will be those whose names appear 4072 in this list, and 4073 that are both currently connected and streaming data in real-time 4074 (as shown by a state of <literal>streaming</literal> in the 4075 <link linkend="monitoring-pg-stat-replication-view"> 4076 <structname>pg_stat_replication</structname></link> view). 4077 Specifying more than one synchronous standby can allow for very high 4078 availability and protection against data loss. 4079 </para> 4080 <para> 4081 The name of a standby server for this purpose is the 4082 <varname>application_name</varname> setting of the standby, as set in the 4083 standby's connection information. In case of a physical replication 4084 standby, this should be set in the <varname>primary_conninfo</varname> 4085 setting; the default is the setting of <xref linkend="guc-cluster-name"/> 4086 if set, else <literal>walreceiver</literal>. 4087 For logical replication, this can be set in the connection 4088 information of the subscription, and it defaults to the 4089 subscription name. For other replication stream consumers, 4090 consult their documentation. 4091 </para> 4092 <para> 4093 This parameter specifies a list of standby servers using 4094 either of the following syntaxes: 4095<synopsis> 4096[FIRST] <replaceable class="parameter">num_sync</replaceable> ( <replaceable class="parameter">standby_name</replaceable> [, ...] ) 4097ANY <replaceable class="parameter">num_sync</replaceable> ( <replaceable class="parameter">standby_name</replaceable> [, ...] ) 4098<replaceable class="parameter">standby_name</replaceable> [, ...] 4099</synopsis> 4100 where <replaceable class="parameter">num_sync</replaceable> is 4101 the number of synchronous standbys that transactions need to 4102 wait for replies from, 4103 and <replaceable class="parameter">standby_name</replaceable> 4104 is the name of a standby server. 4105 <literal>FIRST</literal> and <literal>ANY</literal> specify the method to choose 4106 synchronous standbys from the listed servers. 4107 </para> 4108 <para> 4109 The keyword <literal>FIRST</literal>, coupled with 4110 <replaceable class="parameter">num_sync</replaceable>, specifies a 4111 priority-based synchronous replication and makes transaction commits 4112 wait until their WAL records are replicated to 4113 <replaceable class="parameter">num_sync</replaceable> synchronous 4114 standbys chosen based on their priorities. For example, a setting of 4115 <literal>FIRST 3 (s1, s2, s3, s4)</literal> will cause each commit to wait for 4116 replies from three higher-priority standbys chosen from standby servers 4117 <literal>s1</literal>, <literal>s2</literal>, <literal>s3</literal> and <literal>s4</literal>. 4118 The standbys whose names appear earlier in the list are given higher 4119 priority and will be considered as synchronous. Other standby servers 4120 appearing later in this list represent potential synchronous standbys. 4121 If any of the current synchronous standbys disconnects for whatever 4122 reason, it will be replaced immediately with the next-highest-priority 4123 standby. The keyword <literal>FIRST</literal> is optional. 4124 </para> 4125 <para> 4126 The keyword <literal>ANY</literal>, coupled with 4127 <replaceable class="parameter">num_sync</replaceable>, specifies a 4128 quorum-based synchronous replication and makes transaction commits 4129 wait until their WAL records are replicated to <emphasis>at least</emphasis> 4130 <replaceable class="parameter">num_sync</replaceable> listed standbys. 4131 For example, a setting of <literal>ANY 3 (s1, s2, s3, s4)</literal> will cause 4132 each commit to proceed as soon as at least any three standbys of 4133 <literal>s1</literal>, <literal>s2</literal>, <literal>s3</literal> and <literal>s4</literal> 4134 reply. 4135 </para> 4136 <para> 4137 <literal>FIRST</literal> and <literal>ANY</literal> are case-insensitive. If these 4138 keywords are used as the name of a standby server, 4139 its <replaceable class="parameter">standby_name</replaceable> must 4140 be double-quoted. 4141 </para> 4142 <para> 4143 The third syntax was used before <productname>PostgreSQL</productname> 4144 version 9.6 and is still supported. It's the same as the first syntax 4145 with <literal>FIRST</literal> and 4146 <replaceable class="parameter">num_sync</replaceable> equal to 1. 4147 For example, <literal>FIRST 1 (s1, s2)</literal> and <literal>s1, s2</literal> have 4148 the same meaning: either <literal>s1</literal> or <literal>s2</literal> is chosen 4149 as a synchronous standby. 4150 </para> 4151 <para> 4152 The special entry <literal>*</literal> matches any standby name. 4153 </para> 4154 <para> 4155 There is no mechanism to enforce uniqueness of standby names. In case 4156 of duplicates one of the matching standbys will be considered as 4157 higher priority, though exactly which one is indeterminate. 4158 </para> 4159 <note> 4160 <para> 4161 Each <replaceable class="parameter">standby_name</replaceable> 4162 should have the form of a valid SQL identifier, unless it 4163 is <literal>*</literal>. You can use double-quoting if necessary. But note 4164 that <replaceable class="parameter">standby_name</replaceable>s are 4165 compared to standby application names case-insensitively, whether 4166 double-quoted or not. 4167 </para> 4168 </note> 4169 <para> 4170 If no synchronous standby names are specified here, then synchronous 4171 replication is not enabled and transaction commits will not wait for 4172 replication. This is the default configuration. Even when 4173 synchronous replication is enabled, individual transactions can be 4174 configured not to wait for replication by setting the 4175 <xref linkend="guc-synchronous-commit"/> parameter to 4176 <literal>local</literal> or <literal>off</literal>. 4177 </para> 4178 <para> 4179 This parameter can only be set in the <filename>postgresql.conf</filename> 4180 file or on the server command line. 4181 </para> 4182 </listitem> 4183 </varlistentry> 4184 4185 <varlistentry id="guc-vacuum-defer-cleanup-age" xreflabel="vacuum_defer_cleanup_age"> 4186 <term><varname>vacuum_defer_cleanup_age</varname> (<type>integer</type>) 4187 <indexterm> 4188 <primary><varname>vacuum_defer_cleanup_age</varname> configuration parameter</primary> 4189 </indexterm> 4190 </term> 4191 <listitem> 4192 <para> 4193 Specifies the number of transactions by which <command>VACUUM</command> and 4194 <acronym>HOT</acronym> updates will defer cleanup of dead row versions. The 4195 default is zero transactions, meaning that dead row versions can be 4196 removed as soon as possible, that is, as soon as they are no longer 4197 visible to any open transaction. You may wish to set this to a 4198 non-zero value on a primary server that is supporting hot standby 4199 servers, as described in <xref linkend="hot-standby"/>. This allows 4200 more time for queries on the standby to complete without incurring 4201 conflicts due to early cleanup of rows. However, since the value 4202 is measured in terms of number of write transactions occurring on the 4203 primary server, it is difficult to predict just how much additional 4204 grace time will be made available to standby queries. 4205 This parameter can only be set in the <filename>postgresql.conf</filename> 4206 file or on the server command line. 4207 </para> 4208 <para> 4209 You should also consider setting <varname>hot_standby_feedback</varname> 4210 on standby server(s) as an alternative to using this parameter. 4211 </para> 4212 <para> 4213 This does not prevent cleanup of dead rows which have reached the age 4214 specified by <varname>old_snapshot_threshold</varname>. 4215 </para> 4216 </listitem> 4217 </varlistentry> 4218 4219 </variablelist> 4220 </sect2> 4221 4222 <sect2 id="runtime-config-replication-standby"> 4223 <title>Standby Servers</title> 4224 4225 <para> 4226 These settings control the behavior of a 4227 <link linkend="standby-server-operation">standby server</link> 4228 that is to receive replication data. Their values on the master server 4229 are irrelevant. 4230 </para> 4231 4232 <variablelist> 4233 4234 <varlistentry id="guc-primary-conninfo" xreflabel="primary_conninfo"> 4235 <term><varname>primary_conninfo</varname> (<type>string</type>) 4236 <indexterm> 4237 <primary><varname>primary_conninfo</varname> configuration parameter</primary> 4238 </indexterm> 4239 </term> 4240 <listitem> 4241 <para> 4242 Specifies a connection string to be used for the standby server 4243 to connect with a sending server. This string is in the format 4244 described in <xref linkend="libpq-connstring"/>. If any option is 4245 unspecified in this string, then the corresponding environment 4246 variable (see <xref linkend="libpq-envars"/>) is checked. If the 4247 environment variable is not set either, then 4248 defaults are used. 4249 </para> 4250 <para> 4251 The connection string should specify the host name (or address) 4252 of the sending server, as well as the port number if it is not 4253 the same as the standby server's default. 4254 Also specify a user name corresponding to a suitably-privileged role 4255 on the sending server (see 4256 <xref linkend="streaming-replication-authentication"/>). 4257 A password needs to be provided too, if the sender demands password 4258 authentication. It can be provided in the 4259 <varname>primary_conninfo</varname> string, or in a separate 4260 <filename>~/.pgpass</filename> file on the standby server (use 4261 <literal>replication</literal> as the database name). 4262 Do not specify a database name in the 4263 <varname>primary_conninfo</varname> string. 4264 </para> 4265 <para> 4266 This parameter can only be set in the <filename>postgresql.conf</filename> 4267 file or on the server command line. 4268 If this parameter is changed while the WAL receiver process is 4269 running, that process is signaled to shut down and expected to 4270 restart with the new setting (except if <varname>primary_conninfo</varname> 4271 is an empty string). 4272 This setting has no effect if the server is not in standby mode. 4273 </para> 4274 </listitem> 4275 </varlistentry> 4276 <varlistentry id="guc-primary-slot-name" xreflabel="primary_slot_name"> 4277 <term><varname>primary_slot_name</varname> (<type>string</type>) 4278 <indexterm> 4279 <primary><varname>primary_slot_name</varname> configuration parameter</primary> 4280 </indexterm> 4281 </term> 4282 <listitem> 4283 <para> 4284 Optionally specifies an existing replication slot to be used when 4285 connecting to the sending server via streaming replication to control 4286 resource removal on the upstream node 4287 (see <xref linkend="streaming-replication-slots"/>). 4288 This parameter can only be set in the <filename>postgresql.conf</filename> 4289 file or on the server command line. 4290 If this parameter is changed while the WAL receiver process is running, 4291 that process is signaled to shut down and expected to restart with the 4292 new setting. 4293 This setting has no effect if <varname>primary_conninfo</varname> is not 4294 set or the server is not in standby mode. 4295 </para> 4296 </listitem> 4297 </varlistentry> 4298 4299 <varlistentry id="guc-promote-trigger-file" xreflabel="promote_trigger_file"> 4300 <term><varname>promote_trigger_file</varname> (<type>string</type>) 4301 <indexterm> 4302 <primary><varname>promote_trigger_file</varname> configuration parameter</primary> 4303 </indexterm> 4304 </term> 4305 <listitem> 4306 <para> 4307 Specifies a trigger file whose presence ends recovery in the 4308 standby. Even if this value is not set, you can still promote 4309 the standby using <command>pg_ctl promote</command> or calling 4310 <function>pg_promote()</function>. 4311 This parameter can only be set in the <filename>postgresql.conf</filename> 4312 file or on the server command line. 4313 </para> 4314 </listitem> 4315 </varlistentry> 4316 4317 <varlistentry id="guc-hot-standby" xreflabel="hot_standby"> 4318 <term><varname>hot_standby</varname> (<type>boolean</type>) 4319 <indexterm> 4320 <primary><varname>hot_standby</varname> configuration parameter</primary> 4321 </indexterm> 4322 </term> 4323 <listitem> 4324 <para> 4325 Specifies whether or not you can connect and run queries during 4326 recovery, as described in <xref linkend="hot-standby"/>. 4327 The default value is <literal>on</literal>. 4328 This parameter can only be set at server start. It only has effect 4329 during archive recovery or in standby mode. 4330 </para> 4331 </listitem> 4332 </varlistentry> 4333 4334 <varlistentry id="guc-max-standby-archive-delay" xreflabel="max_standby_archive_delay"> 4335 <term><varname>max_standby_archive_delay</varname> (<type>integer</type>) 4336 <indexterm> 4337 <primary><varname>max_standby_archive_delay</varname> configuration parameter</primary> 4338 </indexterm> 4339 </term> 4340 <listitem> 4341 <para> 4342 When Hot Standby is active, this parameter determines how long the 4343 standby server should wait before canceling standby queries that 4344 conflict with about-to-be-applied WAL entries, as described in 4345 <xref linkend="hot-standby-conflict"/>. 4346 <varname>max_standby_archive_delay</varname> applies when WAL data is 4347 being read from WAL archive (and is therefore not current). 4348 If this value is specified without units, it is taken as milliseconds. 4349 The default is 30 seconds. 4350 A value of -1 allows the standby to wait forever for conflicting 4351 queries to complete. 4352 This parameter can only be set in the <filename>postgresql.conf</filename> 4353 file or on the server command line. 4354 </para> 4355 <para> 4356 Note that <varname>max_standby_archive_delay</varname> is not the same as the 4357 maximum length of time a query can run before cancellation; rather it 4358 is the maximum total time allowed to apply any one WAL segment's data. 4359 Thus, if one query has resulted in significant delay earlier in the 4360 WAL segment, subsequent conflicting queries will have much less grace 4361 time. 4362 </para> 4363 </listitem> 4364 </varlistentry> 4365 4366 <varlistentry id="guc-max-standby-streaming-delay" xreflabel="max_standby_streaming_delay"> 4367 <term><varname>max_standby_streaming_delay</varname> (<type>integer</type>) 4368 <indexterm> 4369 <primary><varname>max_standby_streaming_delay</varname> configuration parameter</primary> 4370 </indexterm> 4371 </term> 4372 <listitem> 4373 <para> 4374 When Hot Standby is active, this parameter determines how long the 4375 standby server should wait before canceling standby queries that 4376 conflict with about-to-be-applied WAL entries, as described in 4377 <xref linkend="hot-standby-conflict"/>. 4378 <varname>max_standby_streaming_delay</varname> applies when WAL data is 4379 being received via streaming replication. 4380 If this value is specified without units, it is taken as milliseconds. 4381 The default is 30 seconds. 4382 A value of -1 allows the standby to wait forever for conflicting 4383 queries to complete. 4384 This parameter can only be set in the <filename>postgresql.conf</filename> 4385 file or on the server command line. 4386 </para> 4387 <para> 4388 Note that <varname>max_standby_streaming_delay</varname> is not the same as 4389 the maximum length of time a query can run before cancellation; rather 4390 it is the maximum total time allowed to apply WAL data once it has 4391 been received from the primary server. Thus, if one query has 4392 resulted in significant delay, subsequent conflicting queries will 4393 have much less grace time until the standby server has caught up 4394 again. 4395 </para> 4396 </listitem> 4397 </varlistentry> 4398 4399 <varlistentry id="guc-wal-receiver-create-temp-slot" xreflabel="wal_receiver_create_temp_slot"> 4400 <term><varname>wal_receiver_create_temp_slot</varname> (<type>boolean</type>) 4401 <indexterm> 4402 <primary><varname>wal_receiver_create_temp_slot</varname> configuration parameter</primary> 4403 </indexterm> 4404 </term> 4405 <listitem> 4406 <para> 4407 Specifies whether the WAL receiver process should create a temporary replication 4408 slot on the remote instance when no permanent replication slot to use 4409 has been configured (using <xref linkend="guc-primary-slot-name"/>). 4410 The default is off. This parameter can only be set in the 4411 <filename>postgresql.conf</filename> file or on the server command line. 4412 If this parameter is changed while the WAL receiver process is running, 4413 that process is signaled to shut down and expected to restart with 4414 the new setting. 4415 </para> 4416 </listitem> 4417 </varlistentry> 4418 4419 <varlistentry id="guc-wal-receiver-status-interval" xreflabel="wal_receiver_status_interval"> 4420 <term><varname>wal_receiver_status_interval</varname> (<type>integer</type>) 4421 <indexterm> 4422 <primary><varname>wal_receiver_status_interval</varname> configuration parameter</primary> 4423 </indexterm> 4424 </term> 4425 <listitem> 4426 <para> 4427 Specifies the minimum frequency for the WAL receiver 4428 process on the standby to send information about replication progress 4429 to the primary or upstream standby, where it can be seen using the 4430 <link linkend="monitoring-pg-stat-replication-view"> 4431 <structname>pg_stat_replication</structname></link> 4432 view. The standby will report 4433 the last write-ahead log location it has written, the last position it 4434 has flushed to disk, and the last position it has applied. 4435 This parameter's 4436 value is the maximum amount of time between reports. Updates are 4437 sent each time the write or flush positions change, or at least as 4438 often as specified by this parameter. Thus, the apply position may 4439 lag slightly behind the true position. 4440 If this value is specified without units, it is taken as seconds. 4441 The default value is 10 seconds. 4442 Setting this parameter to zero disables status updates completely. 4443 This parameter can only be set in 4444 the <filename>postgresql.conf</filename> file or on the server 4445 command line. 4446 </para> 4447 </listitem> 4448 </varlistentry> 4449 4450 <varlistentry id="guc-hot-standby-feedback" xreflabel="hot_standby_feedback"> 4451 <term><varname>hot_standby_feedback</varname> (<type>boolean</type>) 4452 <indexterm> 4453 <primary><varname>hot_standby_feedback</varname> configuration parameter</primary> 4454 </indexterm> 4455 </term> 4456 <listitem> 4457 <para> 4458 Specifies whether or not a hot standby will send feedback to the primary 4459 or upstream standby 4460 about queries currently executing on the standby. This parameter can 4461 be used to eliminate query cancels caused by cleanup records, but 4462 can cause database bloat on the primary for some workloads. 4463 Feedback messages will not be sent more frequently than once per 4464 <varname>wal_receiver_status_interval</varname>. The default value is 4465 <literal>off</literal>. This parameter can only be set in the 4466 <filename>postgresql.conf</filename> file or on the server command line. 4467 </para> 4468 <para> 4469 If cascaded replication is in use the feedback is passed upstream 4470 until it eventually reaches the primary. Standbys make no other use 4471 of feedback they receive other than to pass upstream. 4472 </para> 4473 <para> 4474 This setting does not override the behavior of 4475 <varname>old_snapshot_threshold</varname> on the primary; a snapshot on the 4476 standby which exceeds the primary's age threshold can become invalid, 4477 resulting in cancellation of transactions on the standby. This is 4478 because <varname>old_snapshot_threshold</varname> is intended to provide an 4479 absolute limit on the time which dead rows can contribute to bloat, 4480 which would otherwise be violated because of the configuration of a 4481 standby. 4482 </para> 4483 </listitem> 4484 </varlistentry> 4485 4486 <varlistentry id="guc-wal-receiver-timeout" xreflabel="wal_receiver_timeout"> 4487 <term><varname>wal_receiver_timeout</varname> (<type>integer</type>) 4488 <indexterm> 4489 <primary><varname>wal_receiver_timeout</varname> configuration parameter</primary> 4490 </indexterm> 4491 </term> 4492 <listitem> 4493 <para> 4494 Terminate replication connections that are inactive for longer 4495 than this amount of time. This is useful for 4496 the receiving standby server to detect a primary node crash or network 4497 outage. 4498 If this value is specified without units, it is taken as milliseconds. 4499 The default value is 60 seconds. 4500 A value of zero disables the timeout mechanism. 4501 This parameter can only be set in 4502 the <filename>postgresql.conf</filename> file or on the server 4503 command line. 4504 </para> 4505 </listitem> 4506 </varlistentry> 4507 4508 <varlistentry id="guc-wal-retrieve-retry-interval" xreflabel="wal_retrieve_retry_interval"> 4509 <term><varname>wal_retrieve_retry_interval</varname> (<type>integer</type>) 4510 <indexterm> 4511 <primary><varname>wal_retrieve_retry_interval</varname> configuration parameter</primary> 4512 </indexterm> 4513 </term> 4514 <listitem> 4515 <para> 4516 Specifies how long the standby server should wait when WAL data is not 4517 available from any sources (streaming replication, 4518 local <filename>pg_wal</filename> or WAL archive) before trying 4519 again to retrieve WAL data. 4520 If this value is specified without units, it is taken as milliseconds. 4521 The default value is 5 seconds. 4522 This parameter can only be set in 4523 the <filename>postgresql.conf</filename> file or on the server 4524 command line. 4525 </para> 4526 <para> 4527 This parameter is useful in configurations where a node in recovery 4528 needs to control the amount of time to wait for new WAL data to be 4529 available. For example, in archive recovery, it is possible to 4530 make the recovery more responsive in the detection of a new WAL 4531 log file by reducing the value of this parameter. On a system with 4532 low WAL activity, increasing it reduces the amount of requests necessary 4533 to access WAL archives, something useful for example in cloud 4534 environments where the amount of times an infrastructure is accessed 4535 is taken into account. 4536 </para> 4537 </listitem> 4538 </varlistentry> 4539 4540 <varlistentry id="guc-recovery-min-apply-delay" xreflabel="recovery_min_apply_delay"> 4541 <term><varname>recovery_min_apply_delay</varname> (<type>integer</type>) 4542 <indexterm> 4543 <primary><varname>recovery_min_apply_delay</varname> configuration parameter</primary> 4544 </indexterm> 4545 </term> 4546 <listitem> 4547 <para> 4548 By default, a standby server restores WAL records from the 4549 sending server as soon as possible. It may be useful to have a time-delayed 4550 copy of the data, offering opportunities to correct data loss errors. 4551 This parameter allows you to delay recovery by a specified amount 4552 of time. For example, if 4553 you set this parameter to <literal>5min</literal>, the standby will 4554 replay each transaction commit only when the system time on the standby 4555 is at least five minutes past the commit time reported by the master. 4556 If this value is specified without units, it is taken as milliseconds. 4557 The default is zero, adding no delay. 4558 </para> 4559 <para> 4560 It is possible that the replication delay between servers exceeds the 4561 value of this parameter, in which case no delay is added. 4562 Note that the delay is calculated between the WAL time stamp as written 4563 on master and the current time on the standby. Delays in transfer 4564 because of network lag or cascading replication configurations 4565 may reduce the actual wait time significantly. If the system 4566 clocks on master and standby are not synchronized, this may lead to 4567 recovery applying records earlier than expected; but that is not a 4568 major issue because useful settings of this parameter are much larger 4569 than typical time deviations between servers. 4570 </para> 4571 <para> 4572 The delay occurs only on WAL records for transaction commits. 4573 Other records are replayed as quickly as possible, which 4574 is not a problem because MVCC visibility rules ensure their effects 4575 are not visible until the corresponding commit record is applied. 4576 </para> 4577 <para> 4578 The delay occurs once the database in recovery has reached a consistent 4579 state, until the standby is promoted or triggered. After that the standby 4580 will end recovery without further waiting. 4581 </para> 4582 <para> 4583 This parameter is intended for use with streaming replication deployments; 4584 however, if the parameter is specified it will be honored in all cases 4585 except crash recovery. 4586 4587 <varname>hot_standby_feedback</varname> will be delayed by use of this feature 4588 which could lead to bloat on the master; use both together with care. 4589 4590 <warning> 4591 <para> 4592 Synchronous replication is affected by this setting when <varname>synchronous_commit</varname> 4593 is set to <literal>remote_apply</literal>; every <literal>COMMIT</literal> 4594 will need to wait to be applied. 4595 </para> 4596 </warning> 4597 </para> 4598 <para> 4599 This parameter can only be set in the <filename>postgresql.conf</filename> 4600 file or on the server command line. 4601 </para> 4602 </listitem> 4603 </varlistentry> 4604 4605 </variablelist> 4606 </sect2> 4607 4608 <sect2 id="runtime-config-replication-subscriber"> 4609 <title>Subscribers</title> 4610 4611 <para> 4612 These settings control the behavior of a logical replication subscriber. 4613 Their values on the publisher are irrelevant. 4614 </para> 4615 4616 <para> 4617 Note that <varname>wal_receiver_timeout</varname>, 4618 <varname>wal_receiver_status_interval</varname> and 4619 <varname>wal_retrieve_retry_interval</varname> configuration parameters 4620 affect the logical replication workers as well. 4621 </para> 4622 4623 <variablelist> 4624 4625 <varlistentry id="guc-max-logical-replication-workers" xreflabel="max_logical_replication_workers"> 4626 <term><varname>max_logical_replication_workers</varname> (<type>int</type>) 4627 <indexterm> 4628 <primary><varname>max_logical_replication_workers</varname> configuration parameter</primary> 4629 </indexterm> 4630 </term> 4631 <listitem> 4632 <para> 4633 Specifies maximum number of logical replication workers. This includes 4634 both apply workers and table synchronization workers. 4635 </para> 4636 <para> 4637 Logical replication workers are taken from the pool defined by 4638 <varname>max_worker_processes</varname>. 4639 </para> 4640 <para> 4641 The default value is 4. This parameter can only be set at server 4642 start. 4643 </para> 4644 </listitem> 4645 </varlistentry> 4646 4647 <varlistentry id="guc-max-sync-workers-per-subscription" xreflabel="max_sync_workers_per_subscription"> 4648 <term><varname>max_sync_workers_per_subscription</varname> (<type>integer</type>) 4649 <indexterm> 4650 <primary><varname>max_sync_workers_per_subscription</varname> configuration parameter</primary> 4651 </indexterm> 4652 </term> 4653 <listitem> 4654 <para> 4655 Maximum number of synchronization workers per subscription. This 4656 parameter controls the amount of parallelism of the initial data copy 4657 during the subscription initialization or when new tables are added. 4658 </para> 4659 <para> 4660 Currently, there can be only one synchronization worker per table. 4661 </para> 4662 <para> 4663 The synchronization workers are taken from the pool defined by 4664 <varname>max_logical_replication_workers</varname>. 4665 </para> 4666 <para> 4667 The default value is 2. This parameter can only be set in the 4668 <filename>postgresql.conf</filename> file or on the server command 4669 line. 4670 </para> 4671 </listitem> 4672 </varlistentry> 4673 4674 </variablelist> 4675 </sect2> 4676 4677 </sect1> 4678 4679 <sect1 id="runtime-config-query"> 4680 <title>Query Planning</title> 4681 4682 <sect2 id="runtime-config-query-enable"> 4683 <title>Planner Method Configuration</title> 4684 4685 <para> 4686 These configuration parameters provide a crude method of 4687 influencing the query plans chosen by the query optimizer. If 4688 the default plan chosen by the optimizer for a particular query 4689 is not optimal, a <emphasis>temporary</emphasis> solution is to use one 4690 of these configuration parameters to force the optimizer to 4691 choose a different plan. 4692 Better ways to improve the quality of the 4693 plans chosen by the optimizer include adjusting the planner cost 4694 constants (see <xref linkend="runtime-config-query-constants"/>), 4695 running <xref linkend="sql-analyze"/> manually, increasing 4696 the value of the <xref 4697 linkend="guc-default-statistics-target"/> configuration parameter, 4698 and increasing the amount of statistics collected for 4699 specific columns using <command>ALTER TABLE SET 4700 STATISTICS</command>. 4701 </para> 4702 4703 <variablelist> 4704 <varlistentry id="guc-enable-bitmapscan" xreflabel="enable_bitmapscan"> 4705 <term><varname>enable_bitmapscan</varname> (<type>boolean</type>) 4706 <indexterm> 4707 <primary>bitmap scan</primary> 4708 </indexterm> 4709 <indexterm> 4710 <primary><varname>enable_bitmapscan</varname> configuration parameter</primary> 4711 </indexterm> 4712 </term> 4713 <listitem> 4714 <para> 4715 Enables or disables the query planner's use of bitmap-scan plan 4716 types. The default is <literal>on</literal>. 4717 </para> 4718 </listitem> 4719 </varlistentry> 4720 4721 <varlistentry id="guc-enable-gathermerge" xreflabel="enable_gathermerge"> 4722 <term><varname>enable_gathermerge</varname> (<type>boolean</type>) 4723 <indexterm> 4724 <primary><varname>enable_gathermerge</varname> configuration parameter</primary> 4725 </indexterm> 4726 </term> 4727 <listitem> 4728 <para> 4729 Enables or disables the query planner's use of gather 4730 merge plan types. The default is <literal>on</literal>. 4731 </para> 4732 </listitem> 4733 </varlistentry> 4734 4735 <varlistentry id="guc-enable-hashagg" xreflabel="enable_hashagg"> 4736 <term><varname>enable_hashagg</varname> (<type>boolean</type>) 4737 <indexterm> 4738 <primary><varname>enable_hashagg</varname> configuration parameter</primary> 4739 </indexterm> 4740 </term> 4741 <listitem> 4742 <para> 4743 Enables or disables the query planner's use of hashed 4744 aggregation plan types. The default is <literal>on</literal>. 4745 </para> 4746 </listitem> 4747 </varlistentry> 4748 4749 <varlistentry id="guc-enable-hashjoin" xreflabel="enable_hashjoin"> 4750 <term><varname>enable_hashjoin</varname> (<type>boolean</type>) 4751 <indexterm> 4752 <primary><varname>enable_hashjoin</varname> configuration parameter</primary> 4753 </indexterm> 4754 </term> 4755 <listitem> 4756 <para> 4757 Enables or disables the query planner's use of hash-join plan 4758 types. The default is <literal>on</literal>. 4759 </para> 4760 </listitem> 4761 </varlistentry> 4762 4763 <varlistentry id="guc-enable-incremental-sort" xreflabel="enable_incremental_sort"> 4764 <term><varname>enable_incremental_sort</varname> (<type>boolean</type>) 4765 <indexterm> 4766 <primary><varname>enable_incremental_sort</varname> configuration parameter</primary> 4767 </indexterm> 4768 </term> 4769 <listitem> 4770 <para> 4771 Enables or disables the query planner's use of incremental sort steps. 4772 The default is <literal>on</literal>. 4773 </para> 4774 </listitem> 4775 </varlistentry> 4776 4777 <varlistentry id="guc-enable-indexscan" xreflabel="enable_indexscan"> 4778 <term><varname>enable_indexscan</varname> (<type>boolean</type>) 4779 <indexterm> 4780 <primary>index scan</primary> 4781 </indexterm> 4782 <indexterm> 4783 <primary><varname>enable_indexscan</varname> configuration parameter</primary> 4784 </indexterm> 4785 </term> 4786 <listitem> 4787 <para> 4788 Enables or disables the query planner's use of index-scan plan 4789 types. The default is <literal>on</literal>. 4790 </para> 4791 </listitem> 4792 </varlistentry> 4793 4794 <varlistentry id="guc-enable-indexonlyscan" xreflabel="enable_indexonlyscan"> 4795 <term><varname>enable_indexonlyscan</varname> (<type>boolean</type>) 4796 <indexterm> 4797 <primary><varname>enable_indexonlyscan</varname> configuration parameter</primary> 4798 </indexterm> 4799 </term> 4800 <listitem> 4801 <para> 4802 Enables or disables the query planner's use of index-only-scan plan 4803 types (see <xref linkend="indexes-index-only-scans"/>). 4804 The default is <literal>on</literal>. 4805 </para> 4806 </listitem> 4807 </varlistentry> 4808 4809 <varlistentry id="guc-enable-material" xreflabel="enable_material"> 4810 <term><varname>enable_material</varname> (<type>boolean</type>) 4811 <indexterm> 4812 <primary><varname>enable_material</varname> configuration parameter</primary> 4813 </indexterm> 4814 </term> 4815 <listitem> 4816 <para> 4817 Enables or disables the query planner's use of materialization. 4818 It is impossible to suppress materialization entirely, 4819 but turning this variable off prevents the planner from inserting 4820 materialize nodes except in cases where it is required for correctness. 4821 The default is <literal>on</literal>. 4822 </para> 4823 </listitem> 4824 </varlistentry> 4825 4826 <varlistentry id="guc-enable-mergejoin" xreflabel="enable_mergejoin"> 4827 <term><varname>enable_mergejoin</varname> (<type>boolean</type>) 4828 <indexterm> 4829 <primary><varname>enable_mergejoin</varname> configuration parameter</primary> 4830 </indexterm> 4831 </term> 4832 <listitem> 4833 <para> 4834 Enables or disables the query planner's use of merge-join plan 4835 types. The default is <literal>on</literal>. 4836 </para> 4837 </listitem> 4838 </varlistentry> 4839 4840 <varlistentry id="guc-enable-nestloop" xreflabel="enable_nestloop"> 4841 <term><varname>enable_nestloop</varname> (<type>boolean</type>) 4842 <indexterm> 4843 <primary><varname>enable_nestloop</varname> configuration parameter</primary> 4844 </indexterm> 4845 </term> 4846 <listitem> 4847 <para> 4848 Enables or disables the query planner's use of nested-loop join 4849 plans. It is impossible to suppress nested-loop joins entirely, 4850 but turning this variable off discourages the planner from using 4851 one if there are other methods available. The default is 4852 <literal>on</literal>. 4853 </para> 4854 </listitem> 4855 </varlistentry> 4856 4857 <varlistentry id="guc-enable-parallel-append" xreflabel="enable_parallel_append"> 4858 <term><varname>enable_parallel_append</varname> (<type>boolean</type>) 4859 <indexterm> 4860 <primary><varname>enable_parallel_append</varname> configuration parameter</primary> 4861 </indexterm> 4862 </term> 4863 <listitem> 4864 <para> 4865 Enables or disables the query planner's use of parallel-aware 4866 append plan types. The default is <literal>on</literal>. 4867 </para> 4868 </listitem> 4869 </varlistentry> 4870 4871 <varlistentry id="guc-enable-parallel-hash" xreflabel="enable_parallel_hash"> 4872 <term><varname>enable_parallel_hash</varname> (<type>boolean</type>) 4873 <indexterm> 4874 <primary><varname>enable_parallel_hash</varname> configuration parameter</primary> 4875 </indexterm> 4876 </term> 4877 <listitem> 4878 <para> 4879 Enables or disables the query planner's use of hash-join plan 4880 types with parallel hash. Has no effect if hash-join plans are not 4881 also enabled. The default is <literal>on</literal>. 4882 </para> 4883 </listitem> 4884 </varlistentry> 4885 4886 <varlistentry id="guc-enable-partition-pruning" xreflabel="enable_partition_pruning"> 4887 <term><varname>enable_partition_pruning</varname> (<type>boolean</type>) 4888 <indexterm> 4889 <primary><varname>enable_partition_pruning</varname> configuration parameter</primary> 4890 </indexterm> 4891 </term> 4892 <listitem> 4893 <para> 4894 Enables or disables the query planner's ability to eliminate a 4895 partitioned table's partitions from query plans. This also controls 4896 the planner's ability to generate query plans which allow the query 4897 executor to remove (ignore) partitions during query execution. The 4898 default is <literal>on</literal>. 4899 See <xref linkend="ddl-partition-pruning"/> for details. 4900 </para> 4901 </listitem> 4902 </varlistentry> 4903 4904 <varlistentry id="guc-enable-partitionwise-join" xreflabel="enable_partitionwise_join"> 4905 <term><varname>enable_partitionwise_join</varname> (<type>boolean</type>) 4906 <indexterm> 4907 <primary><varname>enable_partitionwise_join</varname> configuration parameter</primary> 4908 </indexterm> 4909 </term> 4910 <listitem> 4911 <para> 4912 Enables or disables the query planner's use of partitionwise join, 4913 which allows a join between partitioned tables to be performed by 4914 joining the matching partitions. Partitionwise join currently applies 4915 only when the join conditions include all the partition keys, which 4916 must be of the same data type and have one-to-one matching sets of 4917 child partitions. Because partitionwise join planning can use 4918 significantly more CPU time and memory during planning, the default is 4919 <literal>off</literal>. 4920 </para> 4921 </listitem> 4922 </varlistentry> 4923 4924 <varlistentry id="guc-enable-partitionwise-aggregate" xreflabel="enable_partitionwise_aggregate"> 4925 <term><varname>enable_partitionwise_aggregate</varname> (<type>boolean</type>) 4926 <indexterm> 4927 <primary><varname>enable_partitionwise_aggregate</varname> configuration parameter</primary> 4928 </indexterm> 4929 </term> 4930 <listitem> 4931 <para> 4932 Enables or disables the query planner's use of partitionwise grouping 4933 or aggregation, which allows grouping or aggregation on a partitioned 4934 tables performed separately for each partition. If the <literal>GROUP 4935 BY</literal> clause does not include the partition keys, only partial 4936 aggregation can be performed on a per-partition basis, and 4937 finalization must be performed later. Because partitionwise grouping 4938 or aggregation can use significantly more CPU time and memory during 4939 planning, the default is <literal>off</literal>. 4940 </para> 4941 </listitem> 4942 </varlistentry> 4943 4944 <varlistentry id="guc-enable-seqscan" xreflabel="enable_seqscan"> 4945 <term><varname>enable_seqscan</varname> (<type>boolean</type>) 4946 <indexterm> 4947 <primary>sequential scan</primary> 4948 </indexterm> 4949 <indexterm> 4950 <primary><varname>enable_seqscan</varname> configuration parameter</primary> 4951 </indexterm> 4952 </term> 4953 <listitem> 4954 <para> 4955 Enables or disables the query planner's use of sequential scan 4956 plan types. It is impossible to suppress sequential scans 4957 entirely, but turning this variable off discourages the planner 4958 from using one if there are other methods available. The 4959 default is <literal>on</literal>. 4960 </para> 4961 </listitem> 4962 </varlistentry> 4963 4964 <varlistentry id="guc-enable-sort" xreflabel="enable_sort"> 4965 <term><varname>enable_sort</varname> (<type>boolean</type>) 4966 <indexterm> 4967 <primary><varname>enable_sort</varname> configuration parameter</primary> 4968 </indexterm> 4969 </term> 4970 <listitem> 4971 <para> 4972 Enables or disables the query planner's use of explicit sort 4973 steps. It is impossible to suppress explicit sorts entirely, 4974 but turning this variable off discourages the planner from 4975 using one if there are other methods available. The default 4976 is <literal>on</literal>. 4977 </para> 4978 </listitem> 4979 </varlistentry> 4980 4981 <varlistentry id="guc-enable-tidscan" xreflabel="enable_tidscan"> 4982 <term><varname>enable_tidscan</varname> (<type>boolean</type>) 4983 <indexterm> 4984 <primary><varname>enable_tidscan</varname> configuration parameter</primary> 4985 </indexterm> 4986 </term> 4987 <listitem> 4988 <para> 4989 Enables or disables the query planner's use of <acronym>TID</acronym> 4990 scan plan types. The default is <literal>on</literal>. 4991 </para> 4992 </listitem> 4993 </varlistentry> 4994 4995 </variablelist> 4996 </sect2> 4997 <sect2 id="runtime-config-query-constants"> 4998 <title>Planner Cost Constants</title> 4999 5000 <para> 5001 The <firstterm>cost</firstterm> variables described in this section are measured 5002 on an arbitrary scale. Only their relative values matter, hence 5003 scaling them all up or down by the same factor will result in no change 5004 in the planner's choices. By default, these cost variables are based on 5005 the cost of sequential page fetches; that is, 5006 <varname>seq_page_cost</varname> is conventionally set to <literal>1.0</literal> 5007 and the other cost variables are set with reference to that. But 5008 you can use a different scale if you prefer, such as actual execution 5009 times in milliseconds on a particular machine. 5010 </para> 5011 5012 <note> 5013 <para> 5014 Unfortunately, there is no well-defined method for determining ideal 5015 values for the cost variables. They are best treated as averages over 5016 the entire mix of queries that a particular installation will receive. This 5017 means that changing them on the basis of just a few experiments is very 5018 risky. 5019 </para> 5020 </note> 5021 5022 <variablelist> 5023 5024 <varlistentry id="guc-seq-page-cost" xreflabel="seq_page_cost"> 5025 <term><varname>seq_page_cost</varname> (<type>floating point</type>) 5026 <indexterm> 5027 <primary><varname>seq_page_cost</varname> configuration parameter</primary> 5028 </indexterm> 5029 </term> 5030 <listitem> 5031 <para> 5032 Sets the planner's estimate of the cost of a disk page fetch 5033 that is part of a series of sequential fetches. The default is 1.0. 5034 This value can be overridden for tables and indexes in a particular 5035 tablespace by setting the tablespace parameter of the same name 5036 (see <xref linkend="sql-altertablespace"/>). 5037 </para> 5038 </listitem> 5039 </varlistentry> 5040 5041 <varlistentry id="guc-random-page-cost" xreflabel="random_page_cost"> 5042 <term><varname>random_page_cost</varname> (<type>floating point</type>) 5043 <indexterm> 5044 <primary><varname>random_page_cost</varname> configuration parameter</primary> 5045 </indexterm> 5046 </term> 5047 <listitem> 5048 <para> 5049 Sets the planner's estimate of the cost of a 5050 non-sequentially-fetched disk page. The default is 4.0. 5051 This value can be overridden for tables and indexes in a particular 5052 tablespace by setting the tablespace parameter of the same name 5053 (see <xref linkend="sql-altertablespace"/>). 5054 </para> 5055 5056 <para> 5057 Reducing this value relative to <varname>seq_page_cost</varname> 5058 will cause the system to prefer index scans; raising it will 5059 make index scans look relatively more expensive. You can raise 5060 or lower both values together to change the importance of disk I/O 5061 costs relative to CPU costs, which are described by the following 5062 parameters. 5063 </para> 5064 5065 <para> 5066 Random access to mechanical disk storage is normally much more expensive 5067 than four times sequential access. However, a lower default is used 5068 (4.0) because the majority of random accesses to disk, such as indexed 5069 reads, are assumed to be in cache. The default value can be thought of 5070 as modeling random access as 40 times slower than sequential, while 5071 expecting 90% of random reads to be cached. 5072 </para> 5073 5074 <para> 5075 If you believe a 90% cache rate is an incorrect assumption 5076 for your workload, you can increase random_page_cost to better 5077 reflect the true cost of random storage reads. Correspondingly, 5078 if your data is likely to be completely in cache, such as when 5079 the database is smaller than the total server memory, decreasing 5080 random_page_cost can be appropriate. Storage that has a low random 5081 read cost relative to sequential, e.g., solid-state drives, might 5082 also be better modeled with a lower value for random_page_cost, 5083 e.g., <literal>1.1</literal>. 5084 </para> 5085 5086 <tip> 5087 <para> 5088 Although the system will let you set <varname>random_page_cost</varname> to 5089 less than <varname>seq_page_cost</varname>, it is not physically sensible 5090 to do so. However, setting them equal makes sense if the database 5091 is entirely cached in RAM, since in that case there is no penalty 5092 for touching pages out of sequence. Also, in a heavily-cached 5093 database you should lower both values relative to the CPU parameters, 5094 since the cost of fetching a page already in RAM is much smaller 5095 than it would normally be. 5096 </para> 5097 </tip> 5098 </listitem> 5099 </varlistentry> 5100 5101 <varlistentry id="guc-cpu-tuple-cost" xreflabel="cpu_tuple_cost"> 5102 <term><varname>cpu_tuple_cost</varname> (<type>floating point</type>) 5103 <indexterm> 5104 <primary><varname>cpu_tuple_cost</varname> configuration parameter</primary> 5105 </indexterm> 5106 </term> 5107 <listitem> 5108 <para> 5109 Sets the planner's estimate of the cost of processing 5110 each row during a query. 5111 The default is 0.01. 5112 </para> 5113 </listitem> 5114 </varlistentry> 5115 5116 <varlistentry id="guc-cpu-index-tuple-cost" xreflabel="cpu_index_tuple_cost"> 5117 <term><varname>cpu_index_tuple_cost</varname> (<type>floating point</type>) 5118 <indexterm> 5119 <primary><varname>cpu_index_tuple_cost</varname> configuration parameter</primary> 5120 </indexterm> 5121 </term> 5122 <listitem> 5123 <para> 5124 Sets the planner's estimate of the cost of processing 5125 each index entry during an index scan. 5126 The default is 0.005. 5127 </para> 5128 </listitem> 5129 </varlistentry> 5130 5131 <varlistentry id="guc-cpu-operator-cost" xreflabel="cpu_operator_cost"> 5132 <term><varname>cpu_operator_cost</varname> (<type>floating point</type>) 5133 <indexterm> 5134 <primary><varname>cpu_operator_cost</varname> configuration parameter</primary> 5135 </indexterm> 5136 </term> 5137 <listitem> 5138 <para> 5139 Sets the planner's estimate of the cost of processing each 5140 operator or function executed during a query. 5141 The default is 0.0025. 5142 </para> 5143 </listitem> 5144 </varlistentry> 5145 5146 <varlistentry id="guc-parallel-setup-cost" xreflabel="parallel_setup_cost"> 5147 <term><varname>parallel_setup_cost</varname> (<type>floating point</type>) 5148 <indexterm> 5149 <primary><varname>parallel_setup_cost</varname> configuration parameter</primary> 5150 </indexterm> 5151 </term> 5152 <listitem> 5153 <para> 5154 Sets the planner's estimate of the cost of launching parallel worker 5155 processes. 5156 The default is 1000. 5157 </para> 5158 </listitem> 5159 </varlistentry> 5160 5161 <varlistentry id="guc-parallel-tuple-cost" xreflabel="parallel_tuple_cost"> 5162 <term><varname>parallel_tuple_cost</varname> (<type>floating point</type>) 5163 <indexterm> 5164 <primary><varname>parallel_tuple_cost</varname> configuration parameter</primary> 5165 </indexterm> 5166 </term> 5167 <listitem> 5168 <para> 5169 Sets the planner's estimate of the cost of transferring one tuple 5170 from a parallel worker process to another process. 5171 The default is 0.1. 5172 </para> 5173 </listitem> 5174 </varlistentry> 5175 5176 <varlistentry id="guc-min-parallel-table-scan-size" xreflabel="min_parallel_table_scan_size"> 5177 <term><varname>min_parallel_table_scan_size</varname> (<type>integer</type>) 5178 <indexterm> 5179 <primary><varname>min_parallel_table_scan_size</varname> configuration parameter</primary> 5180 </indexterm> 5181 </term> 5182 <listitem> 5183 <para> 5184 Sets the minimum amount of table data that must be scanned in order 5185 for a parallel scan to be considered. For a parallel sequential scan, 5186 the amount of table data scanned is always equal to the size of the 5187 table, but when indexes are used the amount of table data 5188 scanned will normally be less. 5189 If this value is specified without units, it is taken as blocks, 5190 that is <symbol>BLCKSZ</symbol> bytes, typically 8kB. 5191 The default is 8 megabytes (<literal>8MB</literal>). 5192 </para> 5193 </listitem> 5194 </varlistentry> 5195 5196 <varlistentry id="guc-min-parallel-index-scan-size" xreflabel="min_parallel_index_scan_size"> 5197 <term><varname>min_parallel_index_scan_size</varname> (<type>integer</type>) 5198 <indexterm> 5199 <primary><varname>min_parallel_index_scan_size</varname> configuration parameter</primary> 5200 </indexterm> 5201 </term> 5202 <listitem> 5203 <para> 5204 Sets the minimum amount of index data that must be scanned in order 5205 for a parallel scan to be considered. Note that a parallel index scan 5206 typically won't touch the entire index; it is the number of pages 5207 which the planner believes will actually be touched by the scan which 5208 is relevant. This parameter is also used to decide whether a 5209 particular index can participate in a parallel vacuum. See 5210 <xref linkend="sql-vacuum"/>. 5211 If this value is specified without units, it is taken as blocks, 5212 that is <symbol>BLCKSZ</symbol> bytes, typically 8kB. 5213 The default is 512 kilobytes (<literal>512kB</literal>). 5214 </para> 5215 </listitem> 5216 </varlistentry> 5217 5218 <varlistentry id="guc-effective-cache-size" xreflabel="effective_cache_size"> 5219 <term><varname>effective_cache_size</varname> (<type>integer</type>) 5220 <indexterm> 5221 <primary><varname>effective_cache_size</varname> configuration parameter</primary> 5222 </indexterm> 5223 </term> 5224 <listitem> 5225 <para> 5226 Sets the planner's assumption about the effective size of the 5227 disk cache that is available to a single query. This is 5228 factored into estimates of the cost of using an index; a 5229 higher value makes it more likely index scans will be used, a 5230 lower value makes it more likely sequential scans will be 5231 used. When setting this parameter you should consider both 5232 <productname>PostgreSQL</productname>'s shared buffers and the 5233 portion of the kernel's disk cache that will be used for 5234 <productname>PostgreSQL</productname> data files, though some 5235 data might exist in both places. Also, take 5236 into account the expected number of concurrent queries on different 5237 tables, since they will have to share the available 5238 space. This parameter has no effect on the size of shared 5239 memory allocated by <productname>PostgreSQL</productname>, nor 5240 does it reserve kernel disk cache; it is used only for estimation 5241 purposes. The system also does not assume data remains in 5242 the disk cache between queries. 5243 If this value is specified without units, it is taken as blocks, 5244 that is <symbol>BLCKSZ</symbol> bytes, typically 8kB. 5245 The default is 4 gigabytes (<literal>4GB</literal>). 5246 (If <symbol>BLCKSZ</symbol> is not 8kB, the default value scales 5247 proportionally to it.) 5248 </para> 5249 </listitem> 5250 </varlistentry> 5251 5252 <varlistentry id="guc-jit-above-cost" xreflabel="jit_above_cost"> 5253 <term><varname>jit_above_cost</varname> (<type>floating point</type>) 5254 <indexterm> 5255 <primary><varname>jit_above_cost</varname> configuration parameter</primary> 5256 </indexterm> 5257 </term> 5258 <listitem> 5259 <para> 5260 Sets the query cost above which JIT compilation is activated, if 5261 enabled (see <xref linkend="jit"/>). 5262 Performing <acronym>JIT</acronym> costs planning time but can 5263 accelerate query execution. 5264 Setting this to <literal>-1</literal> disables JIT compilation. 5265 The default is <literal>100000</literal>. 5266 </para> 5267 </listitem> 5268 </varlistentry> 5269 5270 <varlistentry id="guc-jit-inline-above-cost" xreflabel="jit_inline_above_cost"> 5271 <term><varname>jit_inline_above_cost</varname> (<type>floating point</type>) 5272 <indexterm> 5273 <primary><varname>jit_inline_above_cost</varname> configuration parameter</primary> 5274 </indexterm> 5275 </term> 5276 <listitem> 5277 <para> 5278 Sets the query cost above which JIT compilation attempts to inline 5279 functions and operators. Inlining adds planning time, but can 5280 improve execution speed. It is not meaningful to set this to less 5281 than <varname>jit_above_cost</varname>. 5282 Setting this to <literal>-1</literal> disables inlining. 5283 The default is <literal>500000</literal>. 5284 </para> 5285 </listitem> 5286 </varlistentry> 5287 5288 <varlistentry id="guc-jit-optimize-above-cost" xreflabel="jit_optimize_above_cost"> 5289 <term><varname>jit_optimize_above_cost</varname> (<type>floating point</type>) 5290 <indexterm> 5291 <primary><varname>jit_optimize_above_cost</varname> configuration parameter</primary> 5292 </indexterm> 5293 </term> 5294 <listitem> 5295 <para> 5296 Sets the query cost above which JIT compilation applies expensive 5297 optimizations. Such optimization adds planning time, but can improve 5298 execution speed. It is not meaningful to set this to less 5299 than <varname>jit_above_cost</varname>, and it is unlikely to be 5300 beneficial to set it to more 5301 than <varname>jit_inline_above_cost</varname>. 5302 Setting this to <literal>-1</literal> disables expensive optimizations. 5303 The default is <literal>500000</literal>. 5304 </para> 5305 </listitem> 5306 </varlistentry> 5307 5308 </variablelist> 5309 5310 </sect2> 5311 <sect2 id="runtime-config-query-geqo"> 5312 <title>Genetic Query Optimizer</title> 5313 5314 <para> 5315 The genetic query optimizer (GEQO) is an algorithm that does query 5316 planning using heuristic searching. This reduces planning time for 5317 complex queries (those joining many relations), at the cost of producing 5318 plans that are sometimes inferior to those found by the normal 5319 exhaustive-search algorithm. 5320 For more information see <xref linkend="geqo"/>. 5321 </para> 5322 5323 <variablelist> 5324 5325 <varlistentry id="guc-geqo" xreflabel="geqo"> 5326 <term><varname>geqo</varname> (<type>boolean</type>) 5327 <indexterm> 5328 <primary>genetic query optimization</primary> 5329 </indexterm> 5330 <indexterm> 5331 <primary>GEQO</primary> 5332 <see>genetic query optimization</see> 5333 </indexterm> 5334 <indexterm> 5335 <primary><varname>geqo</varname> configuration parameter</primary> 5336 </indexterm> 5337 </term> 5338 <listitem> 5339 <para> 5340 Enables or disables genetic query optimization. 5341 This is on by default. It is usually best not to turn it off in 5342 production; the <varname>geqo_threshold</varname> variable provides 5343 more granular control of GEQO. 5344 </para> 5345 </listitem> 5346 </varlistentry> 5347 5348 <varlistentry id="guc-geqo-threshold" xreflabel="geqo_threshold"> 5349 <term><varname>geqo_threshold</varname> (<type>integer</type>) 5350 <indexterm> 5351 <primary><varname>geqo_threshold</varname> configuration parameter</primary> 5352 </indexterm> 5353 </term> 5354 <listitem> 5355 <para> 5356 Use genetic query optimization to plan queries with at least 5357 this many <literal>FROM</literal> items involved. (Note that a 5358 <literal>FULL OUTER JOIN</literal> construct counts as only one <literal>FROM</literal> 5359 item.) The default is 12. For simpler queries it is usually best 5360 to use the regular, exhaustive-search planner, but for queries with 5361 many tables the exhaustive search takes too long, often 5362 longer than the penalty of executing a suboptimal plan. Thus, 5363 a threshold on the size of the query is a convenient way to manage 5364 use of GEQO. 5365 </para> 5366 </listitem> 5367 </varlistentry> 5368 5369 <varlistentry id="guc-geqo-effort" xreflabel="geqo_effort"> 5370 <term><varname>geqo_effort</varname> (<type>integer</type>) 5371 <indexterm> 5372 <primary><varname>geqo_effort</varname> configuration parameter</primary> 5373 </indexterm> 5374 </term> 5375 <listitem> 5376 <para> 5377 Controls the trade-off between planning time and query plan 5378 quality in GEQO. This variable must be an integer in the 5379 range from 1 to 10. The default value is five. Larger values 5380 increase the time spent doing query planning, but also 5381 increase the likelihood that an efficient query plan will be 5382 chosen. 5383 </para> 5384 5385 <para> 5386 <varname>geqo_effort</varname> doesn't actually do anything 5387 directly; it is only used to compute the default values for 5388 the other variables that influence GEQO behavior (described 5389 below). If you prefer, you can set the other parameters by 5390 hand instead. 5391 </para> 5392 </listitem> 5393 </varlistentry> 5394 5395 <varlistentry id="guc-geqo-pool-size" xreflabel="geqo_pool_size"> 5396 <term><varname>geqo_pool_size</varname> (<type>integer</type>) 5397 <indexterm> 5398 <primary><varname>geqo_pool_size</varname> configuration parameter</primary> 5399 </indexterm> 5400 </term> 5401 <listitem> 5402 <para> 5403 Controls the pool size used by GEQO, that is the 5404 number of individuals in the genetic population. It must be 5405 at least two, and useful values are typically 100 to 1000. If 5406 it is set to zero (the default setting) then a suitable 5407 value is chosen based on <varname>geqo_effort</varname> and 5408 the number of tables in the query. 5409 </para> 5410 </listitem> 5411 </varlistentry> 5412 5413 <varlistentry id="guc-geqo-generations" xreflabel="geqo_generations"> 5414 <term><varname>geqo_generations</varname> (<type>integer</type>) 5415 <indexterm> 5416 <primary><varname>geqo_generations</varname> configuration parameter</primary> 5417 </indexterm> 5418 </term> 5419 <listitem> 5420 <para> 5421 Controls the number of generations used by GEQO, that is 5422 the number of iterations of the algorithm. It must 5423 be at least one, and useful values are in the same range as 5424 the pool size. If it is set to zero (the default setting) 5425 then a suitable value is chosen based on 5426 <varname>geqo_pool_size</varname>. 5427 </para> 5428 </listitem> 5429 </varlistentry> 5430 5431 <varlistentry id="guc-geqo-selection-bias" xreflabel="geqo_selection_bias"> 5432 <term><varname>geqo_selection_bias</varname> (<type>floating point</type>) 5433 <indexterm> 5434 <primary><varname>geqo_selection_bias</varname> configuration parameter</primary> 5435 </indexterm> 5436 </term> 5437 <listitem> 5438 <para> 5439 Controls the selection bias used by GEQO. The selection bias 5440 is the selective pressure within the population. Values can be 5441 from 1.50 to 2.00; the latter is the default. 5442 </para> 5443 </listitem> 5444 </varlistentry> 5445 5446 <varlistentry id="guc-geqo-seed" xreflabel="geqo_seed"> 5447 <term><varname>geqo_seed</varname> (<type>floating point</type>) 5448 <indexterm> 5449 <primary><varname>geqo_seed</varname> configuration parameter</primary> 5450 </indexterm> 5451 </term> 5452 <listitem> 5453 <para> 5454 Controls the initial value of the random number generator used 5455 by GEQO to select random paths through the join order search space. 5456 The value can range from zero (the default) to one. Varying the 5457 value changes the set of join paths explored, and may result in a 5458 better or worse best path being found. 5459 </para> 5460 </listitem> 5461 </varlistentry> 5462 5463 </variablelist> 5464 </sect2> 5465 <sect2 id="runtime-config-query-other"> 5466 <title>Other Planner Options</title> 5467 5468 <variablelist> 5469 5470 <varlistentry id="guc-default-statistics-target" xreflabel="default_statistics_target"> 5471 <term><varname>default_statistics_target</varname> (<type>integer</type>) 5472 <indexterm> 5473 <primary><varname>default_statistics_target</varname> configuration parameter</primary> 5474 </indexterm> 5475 </term> 5476 <listitem> 5477 <para> 5478 Sets the default statistics target for table columns without 5479 a column-specific target set via <command>ALTER TABLE 5480 SET STATISTICS</command>. Larger values increase the time needed to 5481 do <command>ANALYZE</command>, but might improve the quality of the 5482 planner's estimates. The default is 100. For more information 5483 on the use of statistics by the <productname>PostgreSQL</productname> 5484 query planner, refer to <xref linkend="planner-stats"/>. 5485 </para> 5486 </listitem> 5487 </varlistentry> 5488 5489 <varlistentry id="guc-constraint-exclusion" xreflabel="constraint_exclusion"> 5490 <term><varname>constraint_exclusion</varname> (<type>enum</type>) 5491 <indexterm> 5492 <primary>constraint exclusion</primary> 5493 </indexterm> 5494 <indexterm> 5495 <primary><varname>constraint_exclusion</varname> configuration parameter</primary> 5496 </indexterm> 5497 </term> 5498 <listitem> 5499 <para> 5500 Controls the query planner's use of table constraints to 5501 optimize queries. 5502 The allowed values of <varname>constraint_exclusion</varname> are 5503 <literal>on</literal> (examine constraints for all tables), 5504 <literal>off</literal> (never examine constraints), and 5505 <literal>partition</literal> (examine constraints only for inheritance 5506 child tables and <literal>UNION ALL</literal> subqueries). 5507 <literal>partition</literal> is the default setting. 5508 It is often used with traditional inheritance trees to improve 5509 performance. 5510 </para> 5511 5512 <para> 5513 When this parameter allows it for a particular table, the planner 5514 compares query conditions with the table's <literal>CHECK</literal> 5515 constraints, and omits scanning tables for which the conditions 5516 contradict the constraints. For example: 5517 5518<programlisting> 5519CREATE TABLE parent(key integer, ...); 5520CREATE TABLE child1000(check (key between 1000 and 1999)) INHERITS(parent); 5521CREATE TABLE child2000(check (key between 2000 and 2999)) INHERITS(parent); 5522... 5523SELECT * FROM parent WHERE key = 2400; 5524</programlisting> 5525 5526 With constraint exclusion enabled, this <command>SELECT</command> 5527 will not scan <structname>child1000</structname> at all, improving performance. 5528 </para> 5529 5530 <para> 5531 Currently, constraint exclusion is enabled by default 5532 only for cases that are often used to implement table partitioning via 5533 inheritance trees. Turning it on for all tables imposes extra 5534 planning overhead that is quite noticeable on simple queries, and most 5535 often will yield no benefit for simple queries. If you have no 5536 tables that are partitioned using traditional inheritance, you might 5537 prefer to turn it off entirely. (Note that the equivalent feature for 5538 partitioned tables is controlled by a separate parameter, 5539 <xref linkend="guc-enable-partition-pruning"/>.) 5540 </para> 5541 5542 <para> 5543 Refer to <xref linkend="ddl-partitioning-constraint-exclusion"/> for 5544 more information on using constraint exclusion to implement 5545 partitioning. 5546 </para> 5547 </listitem> 5548 </varlistentry> 5549 5550 <varlistentry id="guc-cursor-tuple-fraction" xreflabel="cursor_tuple_fraction"> 5551 <term><varname>cursor_tuple_fraction</varname> (<type>floating point</type>) 5552 <indexterm> 5553 <primary><varname>cursor_tuple_fraction</varname> configuration parameter</primary> 5554 </indexterm> 5555 </term> 5556 <listitem> 5557 <para> 5558 Sets the planner's estimate of the fraction of a cursor's rows that 5559 will be retrieved. The default is 0.1. Smaller values of this 5560 setting bias the planner towards using <quote>fast start</quote> plans 5561 for cursors, which will retrieve the first few rows quickly while 5562 perhaps taking a long time to fetch all rows. Larger values 5563 put more emphasis on the total estimated time. At the maximum 5564 setting of 1.0, cursors are planned exactly like regular queries, 5565 considering only the total estimated time and not how soon the 5566 first rows might be delivered. 5567 </para> 5568 </listitem> 5569 </varlistentry> 5570 5571 <varlistentry id="guc-from-collapse-limit" xreflabel="from_collapse_limit"> 5572 <term><varname>from_collapse_limit</varname> (<type>integer</type>) 5573 <indexterm> 5574 <primary><varname>from_collapse_limit</varname> configuration parameter</primary> 5575 </indexterm> 5576 </term> 5577 <listitem> 5578 <para> 5579 The planner will merge sub-queries into upper queries if the 5580 resulting <literal>FROM</literal> list would have no more than 5581 this many items. Smaller values reduce planning time but might 5582 yield inferior query plans. The default is eight. 5583 For more information see <xref linkend="explicit-joins"/>. 5584 </para> 5585 5586 <para> 5587 Setting this value to <xref linkend="guc-geqo-threshold"/> or more 5588 may trigger use of the GEQO planner, resulting in non-optimal 5589 plans. See <xref linkend="runtime-config-query-geqo"/>. 5590 </para> 5591 </listitem> 5592 </varlistentry> 5593 5594 <varlistentry id="guc-jit" xreflabel="jit"> 5595 <term><varname>jit</varname> (<type>boolean</type>) 5596 <indexterm> 5597 <primary><varname>jit</varname> configuration parameter</primary> 5598 </indexterm> 5599 </term> 5600 <listitem> 5601 <para> 5602 Determines whether <acronym>JIT</acronym> compilation may be used by 5603 <productname>PostgreSQL</productname>, if available (see <xref 5604 linkend="jit"/>). 5605 The default is <literal>on</literal>. 5606 </para> 5607 </listitem> 5608 </varlistentry> 5609 5610 <varlistentry id="guc-join-collapse-limit" xreflabel="join_collapse_limit"> 5611 <term><varname>join_collapse_limit</varname> (<type>integer</type>) 5612 <indexterm> 5613 <primary><varname>join_collapse_limit</varname> configuration parameter</primary> 5614 </indexterm> 5615 </term> 5616 <listitem> 5617 <para> 5618 The planner will rewrite explicit <literal>JOIN</literal> 5619 constructs (except <literal>FULL JOIN</literal>s) into lists of 5620 <literal>FROM</literal> items whenever a list of no more than this many items 5621 would result. Smaller values reduce planning time but might 5622 yield inferior query plans. 5623 </para> 5624 5625 <para> 5626 By default, this variable is set the same as 5627 <varname>from_collapse_limit</varname>, which is appropriate 5628 for most uses. Setting it to 1 prevents any reordering of 5629 explicit <literal>JOIN</literal>s. Thus, the explicit join order 5630 specified in the query will be the actual order in which the 5631 relations are joined. Because the query planner does not always choose 5632 the optimal join order, advanced users can elect to 5633 temporarily set this variable to 1, and then specify the join 5634 order they desire explicitly. 5635 For more information see <xref linkend="explicit-joins"/>. 5636 </para> 5637 5638 <para> 5639 Setting this value to <xref linkend="guc-geqo-threshold"/> or more 5640 may trigger use of the GEQO planner, resulting in non-optimal 5641 plans. See <xref linkend="runtime-config-query-geqo"/>. 5642 </para> 5643 </listitem> 5644 </varlistentry> 5645 5646 <varlistentry id="guc-parallel-leader-participation" xreflabel="parallel_leader_participation"> 5647 <term> 5648 <varname>parallel_leader_participation</varname> (<type>boolean</type>) 5649 <indexterm> 5650 <primary> 5651 <varname>parallel_leader_participation</varname> configuration 5652 parameter 5653 </primary> 5654 </indexterm> 5655 </term> 5656 <listitem> 5657 <para> 5658 Allows the leader process to execute the query plan under 5659 <literal>Gather</literal> and <literal>Gather Merge</literal> nodes 5660 instead of waiting for worker processes. The default is 5661 <literal>on</literal>. Setting this value to <literal>off</literal> 5662 reduces the likelihood that workers will become blocked because the 5663 leader is not reading tuples fast enough, but requires the leader 5664 process to wait for worker processes to start up before the first 5665 tuples can be produced. The degree to which the leader can help or 5666 hinder performance depends on the plan type, number of workers and 5667 query duration. 5668 </para> 5669 </listitem> 5670 </varlistentry> 5671 5672 <varlistentry id="guc-force-parallel-mode" xreflabel="force_parallel_mode"> 5673 <term><varname>force_parallel_mode</varname> (<type>enum</type>) 5674 <indexterm> 5675 <primary><varname>force_parallel_mode</varname> configuration parameter</primary> 5676 </indexterm> 5677 </term> 5678 <listitem> 5679 <para> 5680 Allows the use of parallel queries for testing purposes even in cases 5681 where no performance benefit is expected. 5682 The allowed values of <varname>force_parallel_mode</varname> are 5683 <literal>off</literal> (use parallel mode only when it is expected to improve 5684 performance), <literal>on</literal> (force parallel query for all queries 5685 for which it is thought to be safe), and <literal>regress</literal> (like 5686 <literal>on</literal>, but with additional behavior changes as explained 5687 below). 5688 </para> 5689 5690 <para> 5691 More specifically, setting this value to <literal>on</literal> will add 5692 a <literal>Gather</literal> node to the top of any query plan for which this 5693 appears to be safe, so that the query runs inside of a parallel worker. 5694 Even when a parallel worker is not available or cannot be used, 5695 operations such as starting a subtransaction that would be prohibited 5696 in a parallel query context will be prohibited unless the planner 5697 believes that this will cause the query to fail. If failures or 5698 unexpected results occur when this option is set, some functions used 5699 by the query may need to be marked <literal>PARALLEL UNSAFE</literal> 5700 (or, possibly, <literal>PARALLEL RESTRICTED</literal>). 5701 </para> 5702 5703 <para> 5704 Setting this value to <literal>regress</literal> has all of the same effects 5705 as setting it to <literal>on</literal> plus some additional effects that are 5706 intended to facilitate automated regression testing. Normally, 5707 messages from a parallel worker include a context line indicating that, 5708 but a setting of <literal>regress</literal> suppresses this line so that the 5709 output is the same as in non-parallel execution. Also, 5710 the <literal>Gather</literal> nodes added to plans by this setting are hidden 5711 in <literal>EXPLAIN</literal> output so that the output matches what 5712 would be obtained if this setting were turned <literal>off</literal>. 5713 </para> 5714 </listitem> 5715 </varlistentry> 5716 5717 <varlistentry id="guc-plan-cache_mode" xreflabel="plan_cache_mode"> 5718 <term><varname>plan_cache_mode</varname> (<type>enum</type>) 5719 <indexterm> 5720 <primary><varname>plan_cache_mode</varname> configuration parameter</primary> 5721 </indexterm> 5722 </term> 5723 <listitem> 5724 <para> 5725 Prepared statements (either explicitly prepared or implicitly 5726 generated, for example by PL/pgSQL) can be executed using custom or 5727 generic plans. Custom plans are made afresh for each execution 5728 using its specific set of parameter values, while generic plans do 5729 not rely on the parameter values and can be re-used across 5730 executions. Thus, use of a generic plan saves planning time, but if 5731 the ideal plan depends strongly on the parameter values then a 5732 generic plan may be inefficient. The choice between these options 5733 is normally made automatically, but it can be overridden 5734 with <varname>plan_cache_mode</varname>. 5735 The allowed values are <literal>auto</literal> (the default), 5736 <literal>force_custom_plan</literal> and 5737 <literal>force_generic_plan</literal>. 5738 This setting is considered when a cached plan is to be executed, 5739 not when it is prepared. 5740 For more information see <xref linkend="sql-prepare"/>. 5741 </para> 5742 </listitem> 5743 </varlistentry> 5744 5745 </variablelist> 5746 </sect2> 5747 </sect1> 5748 5749 <sect1 id="runtime-config-logging"> 5750 <title>Error Reporting and Logging</title> 5751 5752 <indexterm zone="runtime-config-logging"> 5753 <primary>server log</primary> 5754 </indexterm> 5755 5756 <sect2 id="runtime-config-logging-where"> 5757 <title>Where to Log</title> 5758 5759 <indexterm zone="runtime-config-logging-where"> 5760 <primary>where to log</primary> 5761 </indexterm> 5762 5763 <indexterm> 5764 <primary>current_logfiles</primary> 5765 <secondary>and the log_destination configuration parameter</secondary> 5766 </indexterm> 5767 5768 <variablelist> 5769 5770 <varlistentry id="guc-log-destination" xreflabel="log_destination"> 5771 <term><varname>log_destination</varname> (<type>string</type>) 5772 <indexterm> 5773 <primary><varname>log_destination</varname> configuration parameter</primary> 5774 </indexterm> 5775 </term> 5776 <listitem> 5777 <para> 5778 <productname>PostgreSQL</productname> supports several methods 5779 for logging server messages, including 5780 <systemitem>stderr</systemitem>, <systemitem>csvlog</systemitem> and 5781 <systemitem>syslog</systemitem>. On Windows, 5782 <systemitem>eventlog</systemitem> is also supported. Set this 5783 parameter to a list of desired log destinations separated by 5784 commas. The default is to log to <systemitem>stderr</systemitem> 5785 only. 5786 This parameter can only be set in the <filename>postgresql.conf</filename> 5787 file or on the server command line. 5788 </para> 5789 <para> 5790 If <systemitem>csvlog</systemitem> is included in <varname>log_destination</varname>, 5791 log entries are output in <quote>comma separated 5792 value</quote> (<acronym>CSV</acronym>) format, which is convenient for 5793 loading logs into programs. 5794 See <xref linkend="runtime-config-logging-csvlog"/> for details. 5795 <xref linkend="guc-logging-collector"/> must be enabled to generate 5796 CSV-format log output. 5797 </para> 5798 <para> 5799 When either <systemitem>stderr</systemitem> or 5800 <systemitem>csvlog</systemitem> are included, the file 5801 <filename>current_logfiles</filename> is created to record the location 5802 of the log file(s) currently in use by the logging collector and the 5803 associated logging destination. This provides a convenient way to 5804 find the logs currently in use by the instance. Here is an example of 5805 this file's content: 5806<programlisting> 5807stderr log/postgresql.log 5808csvlog log/postgresql.csv 5809</programlisting> 5810 5811 <filename>current_logfiles</filename> is recreated when a new log file 5812 is created as an effect of rotation, and 5813 when <varname>log_destination</varname> is reloaded. It is removed when 5814 neither <systemitem>stderr</systemitem> 5815 nor <systemitem>csvlog</systemitem> are included 5816 in <varname>log_destination</varname>, and when the logging collector is 5817 disabled. 5818 </para> 5819 5820 <note> 5821 <para> 5822 On most Unix systems, you will need to alter the configuration of 5823 your system's <application>syslog</application> daemon in order 5824 to make use of the <systemitem>syslog</systemitem> option for 5825 <varname>log_destination</varname>. <productname>PostgreSQL</productname> 5826 can log to <application>syslog</application> facilities 5827 <literal>LOCAL0</literal> through <literal>LOCAL7</literal> (see <xref 5828 linkend="guc-syslog-facility"/>), but the default 5829 <application>syslog</application> configuration on most platforms 5830 will discard all such messages. You will need to add something like: 5831<programlisting> 5832local0.* /var/log/postgresql 5833</programlisting> 5834 to the <application>syslog</application> daemon's configuration file 5835 to make it work. 5836 </para> 5837 <para> 5838 On Windows, when you use the <literal>eventlog</literal> 5839 option for <varname>log_destination</varname>, you should 5840 register an event source and its library with the operating 5841 system so that the Windows Event Viewer can display event 5842 log messages cleanly. 5843 See <xref linkend="event-log-registration"/> for details. 5844 </para> 5845 </note> 5846 </listitem> 5847 </varlistentry> 5848 5849 <varlistentry id="guc-logging-collector" xreflabel="logging_collector"> 5850 <term><varname>logging_collector</varname> (<type>boolean</type>) 5851 <indexterm> 5852 <primary><varname>logging_collector</varname> configuration parameter</primary> 5853 </indexterm> 5854 </term> 5855 <listitem> 5856 <para> 5857 This parameter enables the <firstterm>logging collector</firstterm>, which 5858 is a background process that captures log messages 5859 sent to <systemitem>stderr</systemitem> and redirects them into log files. 5860 This approach is often more useful than 5861 logging to <application>syslog</application>, since some types of messages 5862 might not appear in <application>syslog</application> output. (One common 5863 example is dynamic-linker failure messages; another is error messages 5864 produced by scripts such as <varname>archive_command</varname>.) 5865 This parameter can only be set at server start. 5866 </para> 5867 5868 <note> 5869 <para> 5870 It is possible to log to <systemitem>stderr</systemitem> without using the 5871 logging collector; the log messages will just go to wherever the 5872 server's <systemitem>stderr</systemitem> is directed. However, that method is 5873 only suitable for low log volumes, since it provides no convenient 5874 way to rotate log files. Also, on some platforms not using the 5875 logging collector can result in lost or garbled log output, because 5876 multiple processes writing concurrently to the same log file can 5877 overwrite each other's output. 5878 </para> 5879 </note> 5880 5881 <note> 5882 <para> 5883 The logging collector is designed to never lose messages. This means 5884 that in case of extremely high load, server processes could be 5885 blocked while trying to send additional log messages when the 5886 collector has fallen behind. In contrast, <application>syslog</application> 5887 prefers to drop messages if it cannot write them, which means it 5888 may fail to log some messages in such cases but it will not block 5889 the rest of the system. 5890 </para> 5891 </note> 5892 5893 </listitem> 5894 </varlistentry> 5895 5896 <varlistentry id="guc-log-directory" xreflabel="log_directory"> 5897 <term><varname>log_directory</varname> (<type>string</type>) 5898 <indexterm> 5899 <primary><varname>log_directory</varname> configuration parameter</primary> 5900 </indexterm> 5901 </term> 5902 <listitem> 5903 <para> 5904 When <varname>logging_collector</varname> is enabled, 5905 this parameter determines the directory in which log files will be created. 5906 It can be specified as an absolute path, or relative to the 5907 cluster data directory. 5908 This parameter can only be set in the <filename>postgresql.conf</filename> 5909 file or on the server command line. 5910 The default is <literal>log</literal>. 5911 </para> 5912 </listitem> 5913 </varlistentry> 5914 5915 <varlistentry id="guc-log-filename" xreflabel="log_filename"> 5916 <term><varname>log_filename</varname> (<type>string</type>) 5917 <indexterm> 5918 <primary><varname>log_filename</varname> configuration parameter</primary> 5919 </indexterm> 5920 </term> 5921 <listitem> 5922 <para> 5923 When <varname>logging_collector</varname> is enabled, 5924 this parameter sets the file names of the created log files. The value 5925 is treated as a <function>strftime</function> pattern, 5926 so <literal>%</literal>-escapes can be used to specify time-varying 5927 file names. (Note that if there are 5928 any time-zone-dependent <literal>%</literal>-escapes, the computation 5929 is done in the zone specified 5930 by <xref linkend="guc-log-timezone"/>.) 5931 The supported <literal>%</literal>-escapes are similar to those 5932 listed in the Open Group's <ulink 5933 url="https://pubs.opengroup.org/onlinepubs/009695399/functions/strftime.html">strftime 5934 </ulink> specification. 5935 Note that the system's <function>strftime</function> is not used 5936 directly, so platform-specific (nonstandard) extensions do not work. 5937 The default is <literal>postgresql-%Y-%m-%d_%H%M%S.log</literal>. 5938 </para> 5939 <para> 5940 If you specify a file name without escapes, you should plan to 5941 use a log rotation utility to avoid eventually filling the 5942 entire disk. In releases prior to 8.4, if 5943 no <literal>%</literal> escapes were 5944 present, <productname>PostgreSQL</productname> would append 5945 the epoch of the new log file's creation time, but this is no 5946 longer the case. 5947 </para> 5948 <para> 5949 If CSV-format output is enabled in <varname>log_destination</varname>, 5950 <literal>.csv</literal> will be appended to the timestamped 5951 log file name to create the file name for CSV-format output. 5952 (If <varname>log_filename</varname> ends in <literal>.log</literal>, the suffix is 5953 replaced instead.) 5954 </para> 5955 <para> 5956 This parameter can only be set in the <filename>postgresql.conf</filename> 5957 file or on the server command line. 5958 </para> 5959 </listitem> 5960 </varlistentry> 5961 5962 <varlistentry id="guc-log-file-mode" xreflabel="log_file_mode"> 5963 <term><varname>log_file_mode</varname> (<type>integer</type>) 5964 <indexterm> 5965 <primary><varname>log_file_mode</varname> configuration parameter</primary> 5966 </indexterm> 5967 </term> 5968 <listitem> 5969 <para> 5970 On Unix systems this parameter sets the permissions for log files 5971 when <varname>logging_collector</varname> is enabled. (On Microsoft 5972 Windows this parameter is ignored.) 5973 The parameter value is expected to be a numeric mode 5974 specified in the format accepted by the 5975 <function>chmod</function> and <function>umask</function> 5976 system calls. (To use the customary octal format the number 5977 must start with a <literal>0</literal> (zero).) 5978 </para> 5979 <para> 5980 The default permissions are <literal>0600</literal>, meaning only the 5981 server owner can read or write the log files. The other commonly 5982 useful setting is <literal>0640</literal>, allowing members of the owner's 5983 group to read the files. Note however that to make use of such a 5984 setting, you'll need to alter <xref linkend="guc-log-directory"/> to 5985 store the files somewhere outside the cluster data directory. In 5986 any case, it's unwise to make the log files world-readable, since 5987 they might contain sensitive data. 5988 </para> 5989 <para> 5990 This parameter can only be set in the <filename>postgresql.conf</filename> 5991 file or on the server command line. 5992 </para> 5993 </listitem> 5994 </varlistentry> 5995 5996 <varlistentry id="guc-log-rotation-age" xreflabel="log_rotation_age"> 5997 <term><varname>log_rotation_age</varname> (<type>integer</type>) 5998 <indexterm> 5999 <primary><varname>log_rotation_age</varname> configuration parameter</primary> 6000 </indexterm> 6001 </term> 6002 <listitem> 6003 <para> 6004 When <varname>logging_collector</varname> is enabled, 6005 this parameter determines the maximum amount of time to use an 6006 individual log file, after which a new log file will be created. 6007 If this value is specified without units, it is taken as minutes. 6008 The default is 24 hours. 6009 Set to zero to disable time-based creation of new log files. 6010 This parameter can only be set in the <filename>postgresql.conf</filename> 6011 file or on the server command line. 6012 </para> 6013 </listitem> 6014 </varlistentry> 6015 6016 <varlistentry id="guc-log-rotation-size" xreflabel="log_rotation_size"> 6017 <term><varname>log_rotation_size</varname> (<type>integer</type>) 6018 <indexterm> 6019 <primary><varname>log_rotation_size</varname> configuration parameter</primary> 6020 </indexterm> 6021 </term> 6022 <listitem> 6023 <para> 6024 When <varname>logging_collector</varname> is enabled, 6025 this parameter determines the maximum size of an individual log file. 6026 After this amount of data has been emitted into a log file, 6027 a new log file will be created. 6028 If this value is specified without units, it is taken as kilobytes. 6029 The default is 10 megabytes. 6030 Set to zero to disable size-based creation of new log files. 6031 This parameter can only be set in the <filename>postgresql.conf</filename> 6032 file or on the server command line. 6033 </para> 6034 </listitem> 6035 </varlistentry> 6036 6037 <varlistentry id="guc-log-truncate-on-rotation" xreflabel="log_truncate_on_rotation"> 6038 <term><varname>log_truncate_on_rotation</varname> (<type>boolean</type>) 6039 <indexterm> 6040 <primary><varname>log_truncate_on_rotation</varname> configuration parameter</primary> 6041 </indexterm> 6042 </term> 6043 <listitem> 6044 <para> 6045 When <varname>logging_collector</varname> is enabled, 6046 this parameter will cause <productname>PostgreSQL</productname> to truncate (overwrite), 6047 rather than append to, any existing log file of the same name. 6048 However, truncation will occur only when a new file is being opened 6049 due to time-based rotation, not during server startup or size-based 6050 rotation. When off, pre-existing files will be appended to in 6051 all cases. For example, using this setting in combination with 6052 a <varname>log_filename</varname> like <literal>postgresql-%H.log</literal> 6053 would result in generating twenty-four hourly log files and then 6054 cyclically overwriting them. 6055 This parameter can only be set in the <filename>postgresql.conf</filename> 6056 file or on the server command line. 6057 </para> 6058 <para> 6059 Example: To keep 7 days of logs, one log file per day named 6060 <literal>server_log.Mon</literal>, <literal>server_log.Tue</literal>, 6061 etc, and automatically overwrite last week's log with this week's log, 6062 set <varname>log_filename</varname> to <literal>server_log.%a</literal>, 6063 <varname>log_truncate_on_rotation</varname> to <literal>on</literal>, and 6064 <varname>log_rotation_age</varname> to <literal>1440</literal>. 6065 </para> 6066 <para> 6067 Example: To keep 24 hours of logs, one log file per hour, but 6068 also rotate sooner if the log file size exceeds 1GB, set 6069 <varname>log_filename</varname> to <literal>server_log.%H%M</literal>, 6070 <varname>log_truncate_on_rotation</varname> to <literal>on</literal>, 6071 <varname>log_rotation_age</varname> to <literal>60</literal>, and 6072 <varname>log_rotation_size</varname> to <literal>1000000</literal>. 6073 Including <literal>%M</literal> in <varname>log_filename</varname> allows 6074 any size-driven rotations that might occur to select a file name 6075 different from the hour's initial file name. 6076 </para> 6077 </listitem> 6078 </varlistentry> 6079 6080 <varlistentry id="guc-syslog-facility" xreflabel="syslog_facility"> 6081 <term><varname>syslog_facility</varname> (<type>enum</type>) 6082 <indexterm> 6083 <primary><varname>syslog_facility</varname> configuration parameter</primary> 6084 </indexterm> 6085 </term> 6086 <listitem> 6087 <para> 6088 When logging to <application>syslog</application> is enabled, this parameter 6089 determines the <application>syslog</application> 6090 <quote>facility</quote> to be used. You can choose 6091 from <literal>LOCAL0</literal>, <literal>LOCAL1</literal>, 6092 <literal>LOCAL2</literal>, <literal>LOCAL3</literal>, <literal>LOCAL4</literal>, 6093 <literal>LOCAL5</literal>, <literal>LOCAL6</literal>, <literal>LOCAL7</literal>; 6094 the default is <literal>LOCAL0</literal>. See also the 6095 documentation of your system's 6096 <application>syslog</application> daemon. 6097 This parameter can only be set in the <filename>postgresql.conf</filename> 6098 file or on the server command line. 6099 </para> 6100 </listitem> 6101 </varlistentry> 6102 6103 <varlistentry id="guc-syslog-ident" xreflabel="syslog_ident"> 6104 <term><varname>syslog_ident</varname> (<type>string</type>) 6105 <indexterm> 6106 <primary><varname>syslog_ident</varname> configuration parameter</primary> 6107 </indexterm> 6108 </term> 6109 <listitem> 6110 <para> 6111 When logging to <application>syslog</application> is enabled, this parameter 6112 determines the program name used to identify 6113 <productname>PostgreSQL</productname> messages in 6114 <application>syslog</application> logs. The default is 6115 <literal>postgres</literal>. 6116 This parameter can only be set in the <filename>postgresql.conf</filename> 6117 file or on the server command line. 6118 </para> 6119 </listitem> 6120 </varlistentry> 6121 6122 <varlistentry id="guc-syslog-sequence-numbers" xreflabel="syslog_sequence_numbers"> 6123 <term><varname>syslog_sequence_numbers</varname> (<type>boolean</type>) 6124 <indexterm> 6125 <primary><varname>syslog_sequence_numbers</varname> configuration parameter</primary> 6126 </indexterm> 6127 </term> 6128 6129 <listitem> 6130 <para> 6131 When logging to <application>syslog</application> and this is on (the 6132 default), then each message will be prefixed by an increasing 6133 sequence number (such as <literal>[2]</literal>). This circumvents 6134 the <quote>--- last message repeated N times ---</quote> suppression 6135 that many syslog implementations perform by default. In more modern 6136 syslog implementations, repeated message suppression can be configured 6137 (for example, <literal>$RepeatedMsgReduction</literal> 6138 in <productname>rsyslog</productname>), so this might not be 6139 necessary. Also, you could turn this off if you actually want to 6140 suppress repeated messages. 6141 </para> 6142 6143 <para> 6144 This parameter can only be set in the <filename>postgresql.conf</filename> 6145 file or on the server command line. 6146 </para> 6147 </listitem> 6148 </varlistentry> 6149 6150 <varlistentry id="guc-syslog-split-messages" xreflabel="syslog_split_messages"> 6151 <term><varname>syslog_split_messages</varname> (<type>boolean</type>) 6152 <indexterm> 6153 <primary><varname>syslog_split_messages</varname> configuration parameter</primary> 6154 </indexterm> 6155 </term> 6156 <listitem> 6157 <para> 6158 When logging to <application>syslog</application> is enabled, this parameter 6159 determines how messages are delivered to syslog. When on (the 6160 default), messages are split by lines, and long lines are split so 6161 that they will fit into 1024 bytes, which is a typical size limit for 6162 traditional syslog implementations. When off, PostgreSQL server log 6163 messages are delivered to the syslog service as is, and it is up to 6164 the syslog service to cope with the potentially bulky messages. 6165 </para> 6166 6167 <para> 6168 If syslog is ultimately logging to a text file, then the effect will 6169 be the same either way, and it is best to leave the setting on, since 6170 most syslog implementations either cannot handle large messages or 6171 would need to be specially configured to handle them. But if syslog 6172 is ultimately writing into some other medium, it might be necessary or 6173 more useful to keep messages logically together. 6174 </para> 6175 6176 <para> 6177 This parameter can only be set in the <filename>postgresql.conf</filename> 6178 file or on the server command line. 6179 </para> 6180 </listitem> 6181 </varlistentry> 6182 6183 <varlistentry id="guc-event-source" xreflabel="event_source"> 6184 <term><varname>event_source</varname> (<type>string</type>) 6185 <indexterm> 6186 <primary><varname>event_source</varname> configuration parameter</primary> 6187 </indexterm> 6188 </term> 6189 <listitem> 6190 <para> 6191 When logging to <application>event log</application> is enabled, this parameter 6192 determines the program name used to identify 6193 <productname>PostgreSQL</productname> messages in 6194 the log. The default is <literal>PostgreSQL</literal>. 6195 This parameter can only be set in the <filename>postgresql.conf</filename> 6196 file or on the server command line. 6197 </para> 6198 </listitem> 6199 </varlistentry> 6200 6201 </variablelist> 6202 </sect2> 6203 <sect2 id="runtime-config-logging-when"> 6204 <title>When to Log</title> 6205 6206 <variablelist> 6207 6208 <varlistentry id="guc-log-min-messages" xreflabel="log_min_messages"> 6209 <term><varname>log_min_messages</varname> (<type>enum</type>) 6210 <indexterm> 6211 <primary><varname>log_min_messages</varname> configuration parameter</primary> 6212 </indexterm> 6213 </term> 6214 <listitem> 6215 <para> 6216 Controls which <link linkend="runtime-config-severity-levels">message 6217 levels</link> are written to the server log. 6218 Valid values are <literal>DEBUG5</literal>, <literal>DEBUG4</literal>, 6219 <literal>DEBUG3</literal>, <literal>DEBUG2</literal>, <literal>DEBUG1</literal>, 6220 <literal>INFO</literal>, <literal>NOTICE</literal>, <literal>WARNING</literal>, 6221 <literal>ERROR</literal>, <literal>LOG</literal>, <literal>FATAL</literal>, and 6222 <literal>PANIC</literal>. Each level includes all the levels that 6223 follow it. The later the level, the fewer messages are sent 6224 to the log. The default is <literal>WARNING</literal>. Note that 6225 <literal>LOG</literal> has a different rank here than in 6226 <xref linkend="guc-client-min-messages"/>. 6227 Only superusers can change this setting. 6228 </para> 6229 </listitem> 6230 </varlistentry> 6231 6232 <varlistentry id="guc-log-min-error-statement" xreflabel="log_min_error_statement"> 6233 <term><varname>log_min_error_statement</varname> (<type>enum</type>) 6234 <indexterm> 6235 <primary><varname>log_min_error_statement</varname> configuration parameter</primary> 6236 </indexterm> 6237 </term> 6238 <listitem> 6239 <para> 6240 Controls which SQL statements that cause an error 6241 condition are recorded in the server log. The current 6242 SQL statement is included in the log entry for any message of 6243 the specified 6244 <link linkend="runtime-config-severity-levels">severity</link> 6245 or higher. 6246 Valid values are <literal>DEBUG5</literal>, 6247 <literal>DEBUG4</literal>, <literal>DEBUG3</literal>, 6248 <literal>DEBUG2</literal>, <literal>DEBUG1</literal>, 6249 <literal>INFO</literal>, <literal>NOTICE</literal>, 6250 <literal>WARNING</literal>, <literal>ERROR</literal>, 6251 <literal>LOG</literal>, 6252 <literal>FATAL</literal>, and <literal>PANIC</literal>. 6253 The default is <literal>ERROR</literal>, which means statements 6254 causing errors, log messages, fatal errors, or panics will be logged. 6255 To effectively turn off logging of failing statements, 6256 set this parameter to <literal>PANIC</literal>. 6257 Only superusers can change this setting. 6258 </para> 6259 </listitem> 6260 </varlistentry> 6261 6262 <varlistentry id="guc-log-min-duration-statement" xreflabel="log_min_duration_statement"> 6263 <term><varname>log_min_duration_statement</varname> (<type>integer</type>) 6264 <indexterm> 6265 <primary><varname>log_min_duration_statement</varname> configuration parameter</primary> 6266 </indexterm> 6267 </term> 6268 <listitem> 6269 <para> 6270 Causes the duration of each completed statement to be logged 6271 if the statement ran for at least the specified amount of time. 6272 For example, if you set it to <literal>250ms</literal> 6273 then all SQL statements that run 250ms or longer will be 6274 logged. Enabling this parameter can be helpful in tracking down 6275 unoptimized queries in your applications. 6276 If this value is specified without units, it is taken as milliseconds. 6277 Setting this to zero prints all statement durations. 6278 <literal>-1</literal> (the default) disables logging statement 6279 durations. Only superusers can change this setting. 6280 </para> 6281 6282 <para> 6283 This overrides <xref linkend="guc-log-min-duration-sample"/>, 6284 meaning that queries with duration exceeding this setting are not 6285 subject to sampling and are always logged. 6286 </para> 6287 6288 <para> 6289 For clients using extended query protocol, durations of the Parse, 6290 Bind, and Execute steps are logged independently. 6291 </para> 6292 6293 <note> 6294 <para> 6295 When using this option together with 6296 <xref linkend="guc-log-statement"/>, 6297 the text of statements that are logged because of 6298 <varname>log_statement</varname> will not be repeated in the 6299 duration log message. 6300 If you are not using <application>syslog</application>, it is recommended 6301 that you log the PID or session ID using 6302 <xref linkend="guc-log-line-prefix"/> 6303 so that you can link the statement message to the later 6304 duration message using the process ID or session ID. 6305 </para> 6306 </note> 6307 </listitem> 6308 </varlistentry> 6309 6310 <varlistentry id="guc-log-min-duration-sample" xreflabel="log_min_duration_sample"> 6311 <term><varname>log_min_duration_sample</varname> (<type>integer</type>) 6312 <indexterm> 6313 <primary><varname>log_min_duration_sample</varname> configuration parameter</primary> 6314 </indexterm> 6315 </term> 6316 <listitem> 6317 <para> 6318 Allows sampling the duration of completed statements that ran for 6319 at least the specified amount of time. This produces the same 6320 kind of log entries as 6321 <xref linkend="guc-log-min-duration-statement"/>, but only for a 6322 subset of the executed statements, with sample rate controlled by 6323 <xref linkend="guc-log-statement-sample-rate"/>. 6324 For example, if you set it to <literal>100ms</literal> then all 6325 SQL statements that run 100ms or longer will be considered for 6326 sampling. Enabling this parameter can be helpful when the 6327 traffic is too high to log all queries. 6328 If this value is specified without units, it is taken as milliseconds. 6329 Setting this to zero samples all statement durations. 6330 <literal>-1</literal> (the default) disables sampling statement 6331 durations. Only superusers can change this setting. 6332 </para> 6333 6334 <para> 6335 This setting has lower priority 6336 than <varname>log_min_duration_statement</varname>, meaning that 6337 statements with durations 6338 exceeding <varname>log_min_duration_statement</varname> are not 6339 subject to sampling and are always logged. 6340 </para> 6341 6342 <para> 6343 Other notes for <varname>log_min_duration_statement</varname> 6344 apply also to this setting. 6345 </para> 6346 </listitem> 6347 </varlistentry> 6348 6349 <varlistentry id="guc-log-statement-sample-rate" xreflabel="log_statement_sample_rate"> 6350 <term><varname>log_statement_sample_rate</varname> (<type>floating point</type>) 6351 <indexterm> 6352 <primary><varname>log_statement_sample_rate</varname> configuration parameter</primary> 6353 </indexterm> 6354 </term> 6355 <listitem> 6356 <para> 6357 Determines the fraction of statements with duration exceeding 6358 <xref linkend="guc-log-min-duration-sample"/> that will be logged. 6359 Sampling is stochastic, for example <literal>0.5</literal> means 6360 there is statistically one chance in two that any given statement 6361 will be logged. 6362 The default is <literal>1.0</literal>, meaning to log all sampled 6363 statements. 6364 Setting this to zero disables sampled statement-duration logging, 6365 the same as setting 6366 <varname>log_min_duration_sample</varname> to 6367 <literal>-1</literal>. 6368 Only superusers can change this setting. 6369 </para> 6370 </listitem> 6371 </varlistentry> 6372 6373 <varlistentry id="guc-log-transaction-sample-rate" xreflabel="log_transaction_sample_rate"> 6374 <term><varname>log_transaction_sample_rate</varname> (<type>floating point</type>) 6375 <indexterm> 6376 <primary><varname>log_transaction_sample_rate</varname> configuration parameter</primary> 6377 </indexterm> 6378 </term> 6379 <listitem> 6380 <para> 6381 Sets the fraction of transactions whose statements are all logged, 6382 in addition to statements logged for other reasons. It applies to 6383 each new transaction regardless of its statements' durations. 6384 Sampling is stochastic, for example <literal>0.1</literal> means 6385 there is statistically one chance in ten that any given transaction 6386 will be logged. 6387 <varname>log_transaction_sample_rate</varname> can be helpful to 6388 construct a sample of transactions. 6389 The default is <literal>0</literal>, meaning not to log 6390 statements from any additional transactions. Setting this 6391 to <literal>1</literal> logs all statements of all transactions. 6392 Only superusers can change this setting. 6393 </para> 6394 <note> 6395 <para> 6396 Like all statement-logging options, this option can add significant 6397 overhead. 6398 </para> 6399 </note> 6400 </listitem> 6401 </varlistentry> 6402 6403 </variablelist> 6404 6405 <para> 6406 <xref linkend="runtime-config-severity-levels"/> explains the message 6407 severity levels used by <productname>PostgreSQL</productname>. If logging output 6408 is sent to <systemitem>syslog</systemitem> or Windows' 6409 <systemitem>eventlog</systemitem>, the severity levels are translated 6410 as shown in the table. 6411 </para> 6412 6413 <table id="runtime-config-severity-levels"> 6414 <title>Message Severity Levels</title> 6415 <tgroup cols="4"> 6416 <colspec colname="col1" colwidth="1*"/> 6417 <colspec colname="col2" colwidth="2*"/> 6418 <colspec colname="col3" colwidth="1*"/> 6419 <colspec colname="col4" colwidth="1*"/> 6420 <thead> 6421 <row> 6422 <entry>Severity</entry> 6423 <entry>Usage</entry> 6424 <entry><systemitem>syslog</systemitem></entry> 6425 <entry><systemitem>eventlog</systemitem></entry> 6426 </row> 6427 </thead> 6428 6429 <tbody> 6430 <row> 6431 <entry><literal>DEBUG1 .. DEBUG5</literal></entry> 6432 <entry>Provides successively-more-detailed information for use by 6433 developers.</entry> 6434 <entry><literal>DEBUG</literal></entry> 6435 <entry><literal>INFORMATION</literal></entry> 6436 </row> 6437 6438 <row> 6439 <entry><literal>INFO</literal></entry> 6440 <entry>Provides information implicitly requested by the user, 6441 e.g., output from <command>VACUUM VERBOSE</command>.</entry> 6442 <entry><literal>INFO</literal></entry> 6443 <entry><literal>INFORMATION</literal></entry> 6444 </row> 6445 6446 <row> 6447 <entry><literal>NOTICE</literal></entry> 6448 <entry>Provides information that might be helpful to users, e.g., 6449 notice of truncation of long identifiers.</entry> 6450 <entry><literal>NOTICE</literal></entry> 6451 <entry><literal>INFORMATION</literal></entry> 6452 </row> 6453 6454 <row> 6455 <entry><literal>WARNING</literal></entry> 6456 <entry>Provides warnings of likely problems, e.g., <command>COMMIT</command> 6457 outside a transaction block.</entry> 6458 <entry><literal>NOTICE</literal></entry> 6459 <entry><literal>WARNING</literal></entry> 6460 </row> 6461 6462 <row> 6463 <entry><literal>ERROR</literal></entry> 6464 <entry>Reports an error that caused the current command to 6465 abort.</entry> 6466 <entry><literal>WARNING</literal></entry> 6467 <entry><literal>ERROR</literal></entry> 6468 </row> 6469 6470 <row> 6471 <entry><literal>LOG</literal></entry> 6472 <entry>Reports information of interest to administrators, e.g., 6473 checkpoint activity.</entry> 6474 <entry><literal>INFO</literal></entry> 6475 <entry><literal>INFORMATION</literal></entry> 6476 </row> 6477 6478 <row> 6479 <entry><literal>FATAL</literal></entry> 6480 <entry>Reports an error that caused the current session to 6481 abort.</entry> 6482 <entry><literal>ERR</literal></entry> 6483 <entry><literal>ERROR</literal></entry> 6484 </row> 6485 6486 <row> 6487 <entry><literal>PANIC</literal></entry> 6488 <entry>Reports an error that caused all database sessions to abort.</entry> 6489 <entry><literal>CRIT</literal></entry> 6490 <entry><literal>ERROR</literal></entry> 6491 </row> 6492 </tbody> 6493 </tgroup> 6494 </table> 6495 6496 </sect2> 6497 <sect2 id="runtime-config-logging-what"> 6498 <title>What to Log</title> 6499 6500 <variablelist> 6501 6502 <varlistentry id="guc-application-name" xreflabel="application_name"> 6503 <term><varname>application_name</varname> (<type>string</type>) 6504 <indexterm> 6505 <primary><varname>application_name</varname> configuration parameter</primary> 6506 </indexterm> 6507 </term> 6508 <listitem> 6509 <para> 6510 The <varname>application_name</varname> can be any string of less than 6511 <symbol>NAMEDATALEN</symbol> characters (64 characters in a standard build). 6512 It is typically set by an application upon connection to the server. 6513 The name will be displayed in the <structname>pg_stat_activity</structname> view 6514 and included in CSV log entries. It can also be included in regular 6515 log entries via the <xref linkend="guc-log-line-prefix"/> parameter. 6516 Only printable ASCII characters may be used in the 6517 <varname>application_name</varname> value. Other characters will be 6518 replaced with question marks (<literal>?</literal>). 6519 </para> 6520 </listitem> 6521 </varlistentry> 6522 6523 <varlistentry> 6524 <term><varname>debug_print_parse</varname> (<type>boolean</type>) 6525 <indexterm> 6526 <primary><varname>debug_print_parse</varname> configuration parameter</primary> 6527 </indexterm> 6528 </term> 6529 <term><varname>debug_print_rewritten</varname> (<type>boolean</type>) 6530 <indexterm> 6531 <primary><varname>debug_print_rewritten</varname> configuration parameter</primary> 6532 </indexterm> 6533 </term> 6534 <term><varname>debug_print_plan</varname> (<type>boolean</type>) 6535 <indexterm> 6536 <primary><varname>debug_print_plan</varname> configuration parameter</primary> 6537 </indexterm> 6538 </term> 6539 <listitem> 6540 <para> 6541 These parameters enable various debugging output to be emitted. 6542 When set, they print the resulting parse tree, the query rewriter 6543 output, or the execution plan for each executed query. 6544 These messages are emitted at <literal>LOG</literal> message level, so by 6545 default they will appear in the server log but will not be sent to the 6546 client. You can change that by adjusting 6547 <xref linkend="guc-client-min-messages"/> and/or 6548 <xref linkend="guc-log-min-messages"/>. 6549 These parameters are off by default. 6550 </para> 6551 </listitem> 6552 </varlistentry> 6553 6554 <varlistentry> 6555 <term><varname>debug_pretty_print</varname> (<type>boolean</type>) 6556 <indexterm> 6557 <primary><varname>debug_pretty_print</varname> configuration parameter</primary> 6558 </indexterm> 6559 </term> 6560 <listitem> 6561 <para> 6562 When set, <varname>debug_pretty_print</varname> indents the messages 6563 produced by <varname>debug_print_parse</varname>, 6564 <varname>debug_print_rewritten</varname>, or 6565 <varname>debug_print_plan</varname>. This results in more readable 6566 but much longer output than the <quote>compact</quote> format used when 6567 it is off. It is on by default. 6568 </para> 6569 </listitem> 6570 </varlistentry> 6571 6572 <varlistentry id="guc-log-checkpoints" xreflabel="log_checkpoints"> 6573 <term><varname>log_checkpoints</varname> (<type>boolean</type>) 6574 <indexterm> 6575 <primary><varname>log_checkpoints</varname> configuration parameter</primary> 6576 </indexterm> 6577 </term> 6578 <listitem> 6579 <para> 6580 Causes checkpoints and restartpoints to be logged in the server log. 6581 Some statistics are included in the log messages, including the number 6582 of buffers written and the time spent writing them. 6583 This parameter can only be set in the <filename>postgresql.conf</filename> 6584 file or on the server command line. The default is off. 6585 </para> 6586 </listitem> 6587 </varlistentry> 6588 6589 <varlistentry id="guc-log-connections" xreflabel="log_connections"> 6590 <term><varname>log_connections</varname> (<type>boolean</type>) 6591 <indexterm> 6592 <primary><varname>log_connections</varname> configuration parameter</primary> 6593 </indexterm> 6594 </term> 6595 <listitem> 6596 <para> 6597 Causes each attempted connection to the server to be logged, 6598 as well as successful completion of client authentication. 6599 Only superusers can change this parameter at session start, 6600 and it cannot be changed at all within a session. 6601 The default is <literal>off</literal>. 6602 </para> 6603 6604 <note> 6605 <para> 6606 Some client programs, like <application>psql</application>, attempt 6607 to connect twice while determining if a password is required, so 6608 duplicate <quote>connection received</quote> messages do not 6609 necessarily indicate a problem. 6610 </para> 6611 </note> 6612 </listitem> 6613 </varlistentry> 6614 6615 <varlistentry id="guc-log-disconnections" xreflabel="log_disconnections"> 6616 <term><varname>log_disconnections</varname> (<type>boolean</type>) 6617 <indexterm> 6618 <primary><varname>log_disconnections</varname> configuration parameter</primary> 6619 </indexterm> 6620 </term> 6621 <listitem> 6622 <para> 6623 Causes session terminations to be logged. The log output 6624 provides information similar to <varname>log_connections</varname>, 6625 plus the duration of the session. 6626 Only superusers can change this parameter at session start, 6627 and it cannot be changed at all within a session. 6628 The default is <literal>off</literal>. 6629 </para> 6630 </listitem> 6631 </varlistentry> 6632 6633 6634 <varlistentry id="guc-log-duration" xreflabel="log_duration"> 6635 <term><varname>log_duration</varname> (<type>boolean</type>) 6636 <indexterm> 6637 <primary><varname>log_duration</varname> configuration parameter</primary> 6638 </indexterm> 6639 </term> 6640 <listitem> 6641 <para> 6642 Causes the duration of every completed statement to be logged. 6643 The default is <literal>off</literal>. 6644 Only superusers can change this setting. 6645 </para> 6646 6647 <para> 6648 For clients using extended query protocol, durations of the Parse, 6649 Bind, and Execute steps are logged independently. 6650 </para> 6651 6652 <note> 6653 <para> 6654 The difference between enabling <varname>log_duration</varname> and setting 6655 <xref linkend="guc-log-min-duration-statement"/> to zero is that 6656 exceeding <varname>log_min_duration_statement</varname> forces the text of 6657 the query to be logged, but this option doesn't. Thus, if 6658 <varname>log_duration</varname> is <literal>on</literal> and 6659 <varname>log_min_duration_statement</varname> has a positive value, all 6660 durations are logged but the query text is included only for 6661 statements exceeding the threshold. This behavior can be useful for 6662 gathering statistics in high-load installations. 6663 </para> 6664 </note> 6665 </listitem> 6666 </varlistentry> 6667 6668 <varlistentry id="guc-log-error-verbosity" xreflabel="log_error_verbosity"> 6669 <term><varname>log_error_verbosity</varname> (<type>enum</type>) 6670 <indexterm> 6671 <primary><varname>log_error_verbosity</varname> configuration parameter</primary> 6672 </indexterm> 6673 </term> 6674 <listitem> 6675 <para> 6676 Controls the amount of detail written in the server log for each 6677 message that is logged. Valid values are <literal>TERSE</literal>, 6678 <literal>DEFAULT</literal>, and <literal>VERBOSE</literal>, each adding more 6679 fields to displayed messages. <literal>TERSE</literal> excludes 6680 the logging of <literal>DETAIL</literal>, <literal>HINT</literal>, 6681 <literal>QUERY</literal>, and <literal>CONTEXT</literal> error information. 6682 <literal>VERBOSE</literal> output includes the <symbol>SQLSTATE</symbol> error 6683 code (see also <xref linkend="errcodes-appendix"/>) and the source code file name, function name, 6684 and line number that generated the error. 6685 Only superusers can change this setting. 6686 </para> 6687 </listitem> 6688 </varlistentry> 6689 6690 <varlistentry id="guc-log-hostname" xreflabel="log_hostname"> 6691 <term><varname>log_hostname</varname> (<type>boolean</type>) 6692 <indexterm> 6693 <primary><varname>log_hostname</varname> configuration parameter</primary> 6694 </indexterm> 6695 </term> 6696 <listitem> 6697 <para> 6698 By default, connection log messages only show the IP address of the 6699 connecting host. Turning this parameter on causes logging of the 6700 host name as well. Note that depending on your host name resolution 6701 setup this might impose a non-negligible performance penalty. 6702 This parameter can only be set in the <filename>postgresql.conf</filename> 6703 file or on the server command line. 6704 </para> 6705 </listitem> 6706 </varlistentry> 6707 6708 <varlistentry id="guc-log-line-prefix" xreflabel="log_line_prefix"> 6709 <term><varname>log_line_prefix</varname> (<type>string</type>) 6710 <indexterm> 6711 <primary><varname>log_line_prefix</varname> configuration parameter</primary> 6712 </indexterm> 6713 </term> 6714 <listitem> 6715 <para> 6716 This is a <function>printf</function>-style string that is output at the 6717 beginning of each log line. 6718 <literal>%</literal> characters begin <quote>escape sequences</quote> 6719 that are replaced with status information as outlined below. 6720 Unrecognized escapes are ignored. Other 6721 characters are copied straight to the log line. Some escapes are 6722 only recognized by session processes, and will be treated as empty by 6723 background processes such as the main server process. Status 6724 information may be aligned either left or right by specifying a 6725 numeric literal after the % and before the option. A negative 6726 value will cause the status information to be padded on the 6727 right with spaces to give it a minimum width, whereas a positive 6728 value will pad on the left. Padding can be useful to aid human 6729 readability in log files. 6730 </para> 6731 6732 <para> 6733 This parameter can only be set in the <filename>postgresql.conf</filename> 6734 file or on the server command line. The default is 6735 <literal>'%m [%p] '</literal> which logs a time stamp and the process ID. 6736 </para> 6737 6738 <informaltable> 6739 <tgroup cols="3"> 6740 <thead> 6741 <row> 6742 <entry>Escape</entry> 6743 <entry>Effect</entry> 6744 <entry>Session only</entry> 6745 </row> 6746 </thead> 6747 <tbody> 6748 <row> 6749 <entry><literal>%a</literal></entry> 6750 <entry>Application name</entry> 6751 <entry>yes</entry> 6752 </row> 6753 <row> 6754 <entry><literal>%u</literal></entry> 6755 <entry>User name</entry> 6756 <entry>yes</entry> 6757 </row> 6758 <row> 6759 <entry><literal>%d</literal></entry> 6760 <entry>Database name</entry> 6761 <entry>yes</entry> 6762 </row> 6763 <row> 6764 <entry><literal>%r</literal></entry> 6765 <entry>Remote host name or IP address, and remote port</entry> 6766 <entry>yes</entry> 6767 </row> 6768 <row> 6769 <entry><literal>%h</literal></entry> 6770 <entry>Remote host name or IP address</entry> 6771 <entry>yes</entry> 6772 </row> 6773 <row> 6774 <entry><literal>%b</literal></entry> 6775 <entry>Backend type</entry> 6776 <entry>no</entry> 6777 </row> 6778 <row> 6779 <entry><literal>%p</literal></entry> 6780 <entry>Process ID</entry> 6781 <entry>no</entry> 6782 </row> 6783 <row> 6784 <entry><literal>%t</literal></entry> 6785 <entry>Time stamp without milliseconds</entry> 6786 <entry>no</entry> 6787 </row> 6788 <row> 6789 <entry><literal>%m</literal></entry> 6790 <entry>Time stamp with milliseconds</entry> 6791 <entry>no</entry> 6792 </row> 6793 <row> 6794 <entry><literal>%n</literal></entry> 6795 <entry>Time stamp with milliseconds (as a Unix epoch)</entry> 6796 <entry>no</entry> 6797 </row> 6798 <row> 6799 <entry><literal>%i</literal></entry> 6800 <entry>Command tag: type of session's current command</entry> 6801 <entry>yes</entry> 6802 </row> 6803 <row> 6804 <entry><literal>%e</literal></entry> 6805 <entry>SQLSTATE error code</entry> 6806 <entry>no</entry> 6807 </row> 6808 <row> 6809 <entry><literal>%c</literal></entry> 6810 <entry>Session ID: see below</entry> 6811 <entry>no</entry> 6812 </row> 6813 <row> 6814 <entry><literal>%l</literal></entry> 6815 <entry>Number of the log line for each session or process, starting at 1</entry> 6816 <entry>no</entry> 6817 </row> 6818 <row> 6819 <entry><literal>%s</literal></entry> 6820 <entry>Process start time stamp</entry> 6821 <entry>no</entry> 6822 </row> 6823 <row> 6824 <entry><literal>%v</literal></entry> 6825 <entry>Virtual transaction ID (backendID/localXID)</entry> 6826 <entry>no</entry> 6827 </row> 6828 <row> 6829 <entry><literal>%x</literal></entry> 6830 <entry>Transaction ID (0 if none is assigned)</entry> 6831 <entry>no</entry> 6832 </row> 6833 <row> 6834 <entry><literal>%q</literal></entry> 6835 <entry>Produces no output, but tells non-session 6836 processes to stop at this point in the string; ignored by 6837 session processes</entry> 6838 <entry>no</entry> 6839 </row> 6840 <row> 6841 <entry><literal>%%</literal></entry> 6842 <entry>Literal <literal>%</literal></entry> 6843 <entry>no</entry> 6844 </row> 6845 </tbody> 6846 </tgroup> 6847 </informaltable> 6848 6849 <para> 6850 The backend type corresponds to the column 6851 <structfield>backend_type</structfield> in the view 6852 <link linkend="monitoring-pg-stat-activity-view"> 6853 <structname>pg_stat_activity</structname></link>, 6854 but additional types can appear 6855 in the log that don't show in that view. 6856 </para> 6857 6858 <para> 6859 The <literal>%c</literal> escape prints a quasi-unique session identifier, 6860 consisting of two 4-byte hexadecimal numbers (without leading zeros) 6861 separated by a dot. The numbers are the process start time and the 6862 process ID, so <literal>%c</literal> can also be used as a space saving way 6863 of printing those items. For example, to generate the session 6864 identifier from <literal>pg_stat_activity</literal>, use this query: 6865<programlisting> 6866SELECT to_hex(trunc(EXTRACT(EPOCH FROM backend_start))::integer) || '.' || 6867 to_hex(pid) 6868FROM pg_stat_activity; 6869</programlisting> 6870 6871 </para> 6872 6873 <tip> 6874 <para> 6875 If you set a nonempty value for <varname>log_line_prefix</varname>, 6876 you should usually make its last character be a space, to provide 6877 visual separation from the rest of the log line. A punctuation 6878 character can be used too. 6879 </para> 6880 </tip> 6881 6882 <tip> 6883 <para> 6884 <application>Syslog</application> produces its own 6885 time stamp and process ID information, so you probably do not want to 6886 include those escapes if you are logging to <application>syslog</application>. 6887 </para> 6888 </tip> 6889 6890 <tip> 6891 <para> 6892 The <literal>%q</literal> escape is useful when including information that is 6893 only available in session (backend) context like user or database 6894 name. For example: 6895<programlisting> 6896log_line_prefix = '%m [%p] %q%u@%d/%a ' 6897</programlisting> 6898 </para> 6899 </tip> 6900 </listitem> 6901 </varlistentry> 6902 6903 <varlistentry id="guc-log-lock-waits" xreflabel="log_lock_waits"> 6904 <term><varname>log_lock_waits</varname> (<type>boolean</type>) 6905 <indexterm> 6906 <primary><varname>log_lock_waits</varname> configuration parameter</primary> 6907 </indexterm> 6908 </term> 6909 <listitem> 6910 <para> 6911 Controls whether a log message is produced when a session waits 6912 longer than <xref linkend="guc-deadlock-timeout"/> to acquire a 6913 lock. This is useful in determining if lock waits are causing 6914 poor performance. The default is <literal>off</literal>. 6915 Only superusers can change this setting. 6916 </para> 6917 </listitem> 6918 </varlistentry> 6919 6920 <varlistentry id="guc-log-parameter-max-length" xreflabel="log_parameter_max_length"> 6921 <term><varname>log_parameter_max_length</varname> (<type>integer</type>) 6922 <indexterm> 6923 <primary><varname>log_parameter_max_length</varname> configuration parameter</primary> 6924 </indexterm> 6925 </term> 6926 <listitem> 6927 <para> 6928 If greater than zero, each bind parameter value logged with a 6929 non-error statement-logging message is trimmed to this many bytes. 6930 Zero disables logging of bind parameters for non-error statement logs. 6931 <literal>-1</literal> (the default) allows bind parameters to be 6932 logged in full. 6933 If this value is specified without units, it is taken as bytes. 6934 Only superusers can change this setting. 6935 </para> 6936 6937 <para> 6938 This setting only affects log messages printed as a result of 6939 <xref linkend="guc-log-statement"/>, 6940 <xref linkend="guc-log-duration"/>, and related settings. Non-zero 6941 values of this setting add some overhead, particularly if parameters 6942 are sent in binary form, since then conversion to text is required. 6943 </para> 6944 </listitem> 6945 </varlistentry> 6946 6947 <varlistentry id="guc-log-parameter-max-length-on-error" xreflabel="log_parameter_max_length_on_error"> 6948 <term><varname>log_parameter_max_length_on_error</varname> (<type>integer</type>) 6949 <indexterm> 6950 <primary><varname>log_parameter_max_length_on_error</varname> configuration parameter</primary> 6951 </indexterm> 6952 </term> 6953 <listitem> 6954 <para> 6955 If greater than zero, each bind parameter value reported in error 6956 messages is trimmed to this many bytes. 6957 Zero (the default) disables including bind parameters in error 6958 messages. 6959 <literal>-1</literal> allows bind parameters to be printed in full. 6960 If this value is specified without units, it is taken as bytes. 6961 </para> 6962 6963 <para> 6964 Non-zero values of this setting add overhead, as 6965 <productname>PostgreSQL</productname> will need to store textual 6966 representations of parameter values in memory at the start of each 6967 statement, whether or not an error eventually occurs. The overhead 6968 is greater when bind parameters are sent in binary form than when 6969 they are sent as text, since the former case requires data 6970 conversion while the latter only requires copying the string. 6971 </para> 6972 </listitem> 6973 </varlistentry> 6974 6975 <varlistentry id="guc-log-statement" xreflabel="log_statement"> 6976 <term><varname>log_statement</varname> (<type>enum</type>) 6977 <indexterm> 6978 <primary><varname>log_statement</varname> configuration parameter</primary> 6979 </indexterm> 6980 </term> 6981 <listitem> 6982 <para> 6983 Controls which SQL statements are logged. Valid values are 6984 <literal>none</literal> (off), <literal>ddl</literal>, <literal>mod</literal>, and 6985 <literal>all</literal> (all statements). <literal>ddl</literal> logs all data definition 6986 statements, such as <command>CREATE</command>, <command>ALTER</command>, and 6987 <command>DROP</command> statements. <literal>mod</literal> logs all 6988 <literal>ddl</literal> statements, plus data-modifying statements 6989 such as <command>INSERT</command>, 6990 <command>UPDATE</command>, <command>DELETE</command>, <command>TRUNCATE</command>, 6991 and <command>COPY FROM</command>. 6992 <command>PREPARE</command>, <command>EXECUTE</command>, and 6993 <command>EXPLAIN ANALYZE</command> statements are also logged if their 6994 contained command is of an appropriate type. For clients using 6995 extended query protocol, logging occurs when an Execute message 6996 is received, and values of the Bind parameters are included 6997 (with any embedded single-quote marks doubled). 6998 </para> 6999 7000 <para> 7001 The default is <literal>none</literal>. Only superusers can change this 7002 setting. 7003 </para> 7004 7005 <note> 7006 <para> 7007 Statements that contain simple syntax errors are not logged 7008 even by the <varname>log_statement</varname> = <literal>all</literal> setting, 7009 because the log message is emitted only after basic parsing has 7010 been done to determine the statement type. In the case of extended 7011 query protocol, this setting likewise does not log statements that 7012 fail before the Execute phase (i.e., during parse analysis or 7013 planning). Set <varname>log_min_error_statement</varname> to 7014 <literal>ERROR</literal> (or lower) to log such statements. 7015 </para> 7016 </note> 7017 </listitem> 7018 </varlistentry> 7019 7020 <varlistentry id="guc-log-replication-commands" xreflabel="log_replication_commands"> 7021 <term><varname>log_replication_commands</varname> (<type>boolean</type>) 7022 <indexterm> 7023 <primary><varname>log_replication_commands</varname> configuration parameter</primary> 7024 </indexterm> 7025 </term> 7026 <listitem> 7027 <para> 7028 Causes each replication command to be logged in the server log. 7029 See <xref linkend="protocol-replication"/> for more information about 7030 replication command. The default value is <literal>off</literal>. 7031 Only superusers can change this setting. 7032 </para> 7033 </listitem> 7034 </varlistentry> 7035 7036 <varlistentry id="guc-log-temp-files" xreflabel="log_temp_files"> 7037 <term><varname>log_temp_files</varname> (<type>integer</type>) 7038 <indexterm> 7039 <primary><varname>log_temp_files</varname> configuration parameter</primary> 7040 </indexterm> 7041 </term> 7042 <listitem> 7043 <para> 7044 Controls logging of temporary file names and sizes. 7045 Temporary files can be 7046 created for sorts, hashes, and temporary query results. 7047 If enabled by this setting, a log entry is emitted for each 7048 temporary file when it is deleted. 7049 A value of zero logs all temporary file information, while positive 7050 values log only files whose size is greater than or equal to 7051 the specified amount of data. 7052 If this value is specified without units, it is taken as kilobytes. 7053 The default setting is -1, which disables such logging. 7054 Only superusers can change this setting. 7055 </para> 7056 </listitem> 7057 </varlistentry> 7058 7059 <varlistentry id="guc-log-timezone" xreflabel="log_timezone"> 7060 <term><varname>log_timezone</varname> (<type>string</type>) 7061 <indexterm> 7062 <primary><varname>log_timezone</varname> configuration parameter</primary> 7063 </indexterm> 7064 </term> 7065 <listitem> 7066 <para> 7067 Sets the time zone used for timestamps written in the server log. 7068 Unlike <xref linkend="guc-timezone"/>, this value is cluster-wide, 7069 so that all sessions will report timestamps consistently. 7070 The built-in default is <literal>GMT</literal>, but that is typically 7071 overridden in <filename>postgresql.conf</filename>; <application>initdb</application> 7072 will install a setting there corresponding to its system environment. 7073 See <xref linkend="datatype-timezones"/> for more information. 7074 This parameter can only be set in the <filename>postgresql.conf</filename> 7075 file or on the server command line. 7076 </para> 7077 </listitem> 7078 </varlistentry> 7079 7080 </variablelist> 7081 </sect2> 7082 <sect2 id="runtime-config-logging-csvlog"> 7083 <title>Using CSV-Format Log Output</title> 7084 7085 <para> 7086 Including <literal>csvlog</literal> in the <varname>log_destination</varname> list 7087 provides a convenient way to import log files into a database table. 7088 This option emits log lines in comma-separated-values 7089 (<acronym>CSV</acronym>) format, 7090 with these columns: 7091 time stamp with milliseconds, 7092 user name, 7093 database name, 7094 process ID, 7095 client host:port number, 7096 session ID, 7097 per-session line number, 7098 command tag, 7099 session start time, 7100 virtual transaction ID, 7101 regular transaction ID, 7102 error severity, 7103 SQLSTATE code, 7104 error message, 7105 error message detail, 7106 hint, 7107 internal query that led to the error (if any), 7108 character count of the error position therein, 7109 error context, 7110 user query that led to the error (if any and enabled by 7111 <varname>log_min_error_statement</varname>), 7112 character count of the error position therein, 7113 location of the error in the PostgreSQL source code 7114 (if <varname>log_error_verbosity</varname> is set to <literal>verbose</literal>), 7115 application name, and backend type. 7116 Here is a sample table definition for storing CSV-format log output: 7117 7118<programlisting> 7119CREATE TABLE postgres_log 7120( 7121 log_time timestamp(3) with time zone, 7122 user_name text, 7123 database_name text, 7124 process_id integer, 7125 connection_from text, 7126 session_id text, 7127 session_line_num bigint, 7128 command_tag text, 7129 session_start_time timestamp with time zone, 7130 virtual_transaction_id text, 7131 transaction_id bigint, 7132 error_severity text, 7133 sql_state_code text, 7134 message text, 7135 detail text, 7136 hint text, 7137 internal_query text, 7138 internal_query_pos integer, 7139 context text, 7140 query text, 7141 query_pos integer, 7142 location text, 7143 application_name text, 7144 backend_type text, 7145 PRIMARY KEY (session_id, session_line_num) 7146); 7147</programlisting> 7148 </para> 7149 7150 <para> 7151 To import a log file into this table, use the <command>COPY FROM</command> 7152 command: 7153 7154<programlisting> 7155COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv; 7156</programlisting> 7157 It is also possible to access the file as a foreign table, using 7158 the supplied <xref linkend="file-fdw"/> module. 7159 </para> 7160 7161 <para> 7162 There are a few things you need to do to simplify importing CSV log 7163 files: 7164 7165 <orderedlist> 7166 <listitem> 7167 <para> 7168 Set <varname>log_filename</varname> and 7169 <varname>log_rotation_age</varname> to provide a consistent, 7170 predictable naming scheme for your log files. This lets you 7171 predict what the file name will be and know when an individual log 7172 file is complete and therefore ready to be imported. 7173 </para> 7174 </listitem> 7175 7176 <listitem> 7177 <para> 7178 Set <varname>log_rotation_size</varname> to 0 to disable 7179 size-based log rotation, as it makes the log file name difficult 7180 to predict. 7181 </para> 7182 </listitem> 7183 7184 <listitem> 7185 <para> 7186 Set <varname>log_truncate_on_rotation</varname> to <literal>on</literal> so 7187 that old log data isn't mixed with the new in the same file. 7188 </para> 7189 </listitem> 7190 7191 <listitem> 7192 <para> 7193 The table definition above includes a primary key specification. 7194 This is useful to protect against accidentally importing the same 7195 information twice. The <command>COPY</command> command commits all of the 7196 data it imports at one time, so any error will cause the entire 7197 import to fail. If you import a partial log file and later import 7198 the file again when it is complete, the primary key violation will 7199 cause the import to fail. Wait until the log is complete and 7200 closed before importing. This procedure will also protect against 7201 accidentally importing a partial line that hasn't been completely 7202 written, which would also cause <command>COPY</command> to fail. 7203 </para> 7204 </listitem> 7205 </orderedlist> 7206 </para> 7207 </sect2> 7208 7209 <sect2> 7210 <title>Process Title</title> 7211 7212 <para> 7213 These settings control how process titles of server processes are 7214 modified. Process titles are typically viewed using programs like 7215 <application>ps</application> or, on Windows, <application>Process Explorer</application>. 7216 See <xref linkend="monitoring-ps"/> for details. 7217 </para> 7218 7219 <variablelist> 7220 <varlistentry id="guc-cluster-name" xreflabel="cluster_name"> 7221 <term><varname>cluster_name</varname> (<type>string</type>) 7222 <indexterm> 7223 <primary><varname>cluster_name</varname> configuration parameter</primary> 7224 </indexterm> 7225 </term> 7226 <listitem> 7227 <para> 7228 Sets a name that identifies this database cluster (instance) for 7229 various purposes. The cluster name appears in the process title for 7230 all server processes in this cluster. Moreover, it is the default 7231 application name for a standby connection (see <xref 7232 linkend="guc-synchronous-standby-names"/>.) 7233 </para> 7234 7235 <para> 7236 The name can be any string of less 7237 than <symbol>NAMEDATALEN</symbol> characters (64 characters in a standard 7238 build). Only printable ASCII characters may be used in the 7239 <varname>cluster_name</varname> value. Other characters will be 7240 replaced with question marks (<literal>?</literal>). No name is shown 7241 if this parameter is set to the empty string <literal>''</literal> (which is 7242 the default). This parameter can only be set at server start. 7243 </para> 7244 </listitem> 7245 </varlistentry> 7246 7247 <varlistentry id="guc-update-process-title" xreflabel="update_process_title"> 7248 <term><varname>update_process_title</varname> (<type>boolean</type>) 7249 <indexterm> 7250 <primary><varname>update_process_title</varname> configuration parameter</primary> 7251 </indexterm> 7252 </term> 7253 <listitem> 7254 <para> 7255 Enables updating of the process title every time a new SQL command 7256 is received by the server. 7257 This setting defaults to <literal>on</literal> on most platforms, but it 7258 defaults to <literal>off</literal> on Windows due to that platform's larger 7259 overhead for updating the process title. 7260 Only superusers can change this setting. 7261 </para> 7262 </listitem> 7263 </varlistentry> 7264 </variablelist> 7265 </sect2> 7266 </sect1> 7267 7268 <sect1 id="runtime-config-statistics"> 7269 <title>Run-time Statistics</title> 7270 7271 <sect2 id="runtime-config-statistics-collector"> 7272 <title>Query and Index Statistics Collector</title> 7273 7274 <para> 7275 These parameters control server-wide statistics collection features. 7276 When statistics collection is enabled, the data that is produced can be 7277 accessed via the <structname>pg_stat</structname> and 7278 <structname>pg_statio</structname> family of system views. 7279 Refer to <xref linkend="monitoring"/> for more information. 7280 </para> 7281 7282 <variablelist> 7283 7284 <varlistentry id="guc-track-activities" xreflabel="track_activities"> 7285 <term><varname>track_activities</varname> (<type>boolean</type>) 7286 <indexterm> 7287 <primary><varname>track_activities</varname> configuration parameter</primary> 7288 </indexterm> 7289 </term> 7290 <listitem> 7291 <para> 7292 Enables the collection of information on the currently 7293 executing command of each session, along with the time when 7294 that command began execution. This parameter is on by 7295 default. Note that even when enabled, this information is not 7296 visible to all users, only to superusers and the user owning 7297 the session being reported on, so it should not represent a 7298 security risk. 7299 Only superusers can change this setting. 7300 </para> 7301 </listitem> 7302 </varlistentry> 7303 7304 <varlistentry id="guc-track-activity-query-size" xreflabel="track_activity_query_size"> 7305 <term><varname>track_activity_query_size</varname> (<type>integer</type>) 7306 <indexterm> 7307 <primary><varname>track_activity_query_size</varname> configuration parameter</primary> 7308 </indexterm> 7309 </term> 7310 <listitem> 7311 <para> 7312 Specifies the amount of memory reserved to store the text of the 7313 currently executing command for each active session, for the 7314 <structname>pg_stat_activity</structname>.<structfield>query</structfield> field. 7315 If this value is specified without units, it is taken as bytes. 7316 The default value is 1024 bytes. 7317 This parameter can only be set at server start. 7318 </para> 7319 </listitem> 7320 </varlistentry> 7321 7322 <varlistentry id="guc-track-counts" xreflabel="track_counts"> 7323 <term><varname>track_counts</varname> (<type>boolean</type>) 7324 <indexterm> 7325 <primary><varname>track_counts</varname> configuration parameter</primary> 7326 </indexterm> 7327 </term> 7328 <listitem> 7329 <para> 7330 Enables collection of statistics on database activity. 7331 This parameter is on by default, because the autovacuum 7332 daemon needs the collected information. 7333 Only superusers can change this setting. 7334 </para> 7335 </listitem> 7336 </varlistentry> 7337 7338 <varlistentry id="guc-track-io-timing" xreflabel="track_io_timing"> 7339 <term><varname>track_io_timing</varname> (<type>boolean</type>) 7340 <indexterm> 7341 <primary><varname>track_io_timing</varname> configuration parameter</primary> 7342 </indexterm> 7343 </term> 7344 <listitem> 7345 <para> 7346 Enables timing of database I/O calls. This parameter is off by 7347 default, because it will repeatedly query the operating system for 7348 the current time, which may cause significant overhead on some 7349 platforms. You can use the <xref linkend="pgtesttiming"/> tool to 7350 measure the overhead of timing on your system. 7351 I/O timing information is 7352 displayed in <link linkend="monitoring-pg-stat-database-view"> 7353 <structname>pg_stat_database</structname></link>, in the output of 7354 <xref linkend="sql-explain"/> when the <literal>BUFFERS</literal> option is 7355 used, and by <xref linkend="pgstatstatements"/>. Only superusers can 7356 change this setting. 7357 </para> 7358 </listitem> 7359 </varlistentry> 7360 7361 <varlistentry id="guc-track-functions" xreflabel="track_functions"> 7362 <term><varname>track_functions</varname> (<type>enum</type>) 7363 <indexterm> 7364 <primary><varname>track_functions</varname> configuration parameter</primary> 7365 </indexterm> 7366 </term> 7367 <listitem> 7368 <para> 7369 Enables tracking of function call counts and time used. Specify 7370 <literal>pl</literal> to track only procedural-language functions, 7371 <literal>all</literal> to also track SQL and C language functions. 7372 The default is <literal>none</literal>, which disables function 7373 statistics tracking. Only superusers can change this setting. 7374 </para> 7375 7376 <note> 7377 <para> 7378 SQL-language functions that are simple enough to be <quote>inlined</quote> 7379 into the calling query will not be tracked, regardless of this 7380 setting. 7381 </para> 7382 </note> 7383 </listitem> 7384 </varlistentry> 7385 7386 <varlistentry id="guc-stats-temp-directory" xreflabel="stats_temp_directory"> 7387 <term><varname>stats_temp_directory</varname> (<type>string</type>) 7388 <indexterm> 7389 <primary><varname>stats_temp_directory</varname> configuration parameter</primary> 7390 </indexterm> 7391 </term> 7392 <listitem> 7393 <para> 7394 Sets the directory to store temporary statistics data in. This can be 7395 a path relative to the data directory or an absolute path. The default 7396 is <filename>pg_stat_tmp</filename>. Pointing this at a RAM-based 7397 file system will decrease physical I/O requirements and can lead to 7398 improved performance. 7399 This parameter can only be set in the <filename>postgresql.conf</filename> 7400 file or on the server command line. 7401 </para> 7402 </listitem> 7403 </varlistentry> 7404 7405 </variablelist> 7406 </sect2> 7407 7408 <sect2 id="runtime-config-statistics-monitor"> 7409 <title>Statistics Monitoring</title> 7410 <variablelist> 7411 7412 <varlistentry> 7413 <term><varname>log_statement_stats</varname> (<type>boolean</type>) 7414 <indexterm> 7415 <primary><varname>log_statement_stats</varname> configuration parameter</primary> 7416 </indexterm> 7417 </term> 7418 <term><varname>log_parser_stats</varname> (<type>boolean</type>) 7419 <indexterm> 7420 <primary><varname>log_parser_stats</varname> configuration parameter</primary> 7421 </indexterm> 7422 </term> 7423 <term><varname>log_planner_stats</varname> (<type>boolean</type>) 7424 <indexterm> 7425 <primary><varname>log_planner_stats</varname> configuration parameter</primary> 7426 </indexterm> 7427 </term> 7428 <term><varname>log_executor_stats</varname> (<type>boolean</type>) 7429 <indexterm> 7430 <primary><varname>log_executor_stats</varname> configuration parameter</primary> 7431 </indexterm> 7432 </term> 7433 <listitem> 7434 <para> 7435 For each query, output performance statistics of the respective 7436 module to the server log. This is a crude profiling 7437 instrument, similar to the Unix <function>getrusage()</function> operating 7438 system facility. <varname>log_statement_stats</varname> reports total 7439 statement statistics, while the others report per-module statistics. 7440 <varname>log_statement_stats</varname> cannot be enabled together with 7441 any of the per-module options. All of these options are disabled by 7442 default. Only superusers can change these settings. 7443 </para> 7444 </listitem> 7445 </varlistentry> 7446 7447 </variablelist> 7448 7449 </sect2> 7450 </sect1> 7451 7452 <sect1 id="runtime-config-autovacuum"> 7453 <title>Automatic Vacuuming</title> 7454 7455 <indexterm> 7456 <primary>autovacuum</primary> 7457 <secondary>configuration parameters</secondary> 7458 </indexterm> 7459 7460 <para> 7461 These settings control the behavior of the <firstterm>autovacuum</firstterm> 7462 feature. Refer to <xref linkend="autovacuum"/> for more information. 7463 Note that many of these settings can be overridden on a per-table 7464 basis; see <xref linkend="sql-createtable-storage-parameters"/>. 7465 </para> 7466 7467 <variablelist> 7468 7469 <varlistentry id="guc-autovacuum" xreflabel="autovacuum"> 7470 <term><varname>autovacuum</varname> (<type>boolean</type>) 7471 <indexterm> 7472 <primary><varname>autovacuum</varname> configuration parameter</primary> 7473 </indexterm> 7474 </term> 7475 <listitem> 7476 <para> 7477 Controls whether the server should run the 7478 autovacuum launcher daemon. This is on by default; however, 7479 <xref linkend="guc-track-counts"/> must also be enabled for 7480 autovacuum to work. 7481 This parameter can only be set in the <filename>postgresql.conf</filename> 7482 file or on the server command line; however, autovacuuming can be 7483 disabled for individual tables by changing table storage parameters. 7484 </para> 7485 <para> 7486 Note that even when this parameter is disabled, the system 7487 will launch autovacuum processes if necessary to 7488 prevent transaction ID wraparound. See <xref 7489 linkend="vacuum-for-wraparound"/> for more information. 7490 </para> 7491 </listitem> 7492 </varlistentry> 7493 7494 <varlistentry id="guc-log-autovacuum-min-duration" xreflabel="log_autovacuum_min_duration"> 7495 <term><varname>log_autovacuum_min_duration</varname> (<type>integer</type>) 7496 <indexterm> 7497 <primary><varname>log_autovacuum_min_duration</varname></primary> 7498 <secondary>configuration parameter</secondary> 7499 </indexterm> 7500 </term> 7501 <listitem> 7502 <para> 7503 Causes each action executed by autovacuum to be logged if it ran for at 7504 least the specified amount of time. Setting this to zero logs 7505 all autovacuum actions. <literal>-1</literal> (the default) disables 7506 logging autovacuum actions. 7507 If this value is specified without units, it is taken as milliseconds. 7508 For example, if you set this to 7509 <literal>250ms</literal> then all automatic vacuums and analyzes that run 7510 250ms or longer will be logged. In addition, when this parameter is 7511 set to any value other than <literal>-1</literal>, a message will be 7512 logged if an autovacuum action is skipped due to a conflicting lock or a 7513 concurrently dropped relation. Enabling this parameter can be helpful 7514 in tracking autovacuum activity. This parameter can only be set in 7515 the <filename>postgresql.conf</filename> file or on the server command line; 7516 but the setting can be overridden for individual tables by 7517 changing table storage parameters. 7518 </para> 7519 </listitem> 7520 </varlistentry> 7521 7522 <varlistentry id="guc-autovacuum-max-workers" xreflabel="autovacuum_max_workers"> 7523 <term><varname>autovacuum_max_workers</varname> (<type>integer</type>) 7524 <indexterm> 7525 <primary><varname>autovacuum_max_workers</varname> configuration parameter</primary> 7526 </indexterm> 7527 </term> 7528 <listitem> 7529 <para> 7530 Specifies the maximum number of autovacuum processes (other than the 7531 autovacuum launcher) that may be running at any one time. The default 7532 is three. This parameter can only be set at server start. 7533 </para> 7534 </listitem> 7535 </varlistentry> 7536 7537 <varlistentry id="guc-autovacuum-naptime" xreflabel="autovacuum_naptime"> 7538 <term><varname>autovacuum_naptime</varname> (<type>integer</type>) 7539 <indexterm> 7540 <primary><varname>autovacuum_naptime</varname> configuration parameter</primary> 7541 </indexterm> 7542 </term> 7543 <listitem> 7544 <para> 7545 Specifies the minimum delay between autovacuum runs on any given 7546 database. In each round the daemon examines the 7547 database and issues <command>VACUUM</command> and <command>ANALYZE</command> commands 7548 as needed for tables in that database. 7549 If this value is specified without units, it is taken as seconds. 7550 The default is one minute (<literal>1min</literal>). 7551 This parameter can only be set in the <filename>postgresql.conf</filename> 7552 file or on the server command line. 7553 </para> 7554 </listitem> 7555 </varlistentry> 7556 7557 <varlistentry id="guc-autovacuum-vacuum-threshold" xreflabel="autovacuum_vacuum_threshold"> 7558 <term><varname>autovacuum_vacuum_threshold</varname> (<type>integer</type>) 7559 <indexterm> 7560 <primary><varname>autovacuum_vacuum_threshold</varname></primary> 7561 <secondary>configuration parameter</secondary> 7562 </indexterm> 7563 </term> 7564 <listitem> 7565 <para> 7566 Specifies the minimum number of updated or deleted tuples needed 7567 to trigger a <command>VACUUM</command> in any one table. 7568 The default is 50 tuples. 7569 This parameter can only be set in the <filename>postgresql.conf</filename> 7570 file or on the server command line; 7571 but the setting can be overridden for individual tables by 7572 changing table storage parameters. 7573 </para> 7574 </listitem> 7575 </varlistentry> 7576 7577 <varlistentry id="guc-autovacuum-vacuum-insert-threshold" xreflabel="autovacuum_vacuum_insert_threshold"> 7578 <term><varname>autovacuum_vacuum_insert_threshold</varname> (<type>integer</type>) 7579 <indexterm> 7580 <primary><varname>autovacuum_vacuum_insert_threshold</varname></primary> 7581 <secondary>configuration parameter</secondary> 7582 </indexterm> 7583 </term> 7584 <listitem> 7585 <para> 7586 Specifies the number of inserted tuples needed to trigger a 7587 <command>VACUUM</command> in any one table. 7588 The default is 1000 tuples. If -1 is specified, autovacuum will not 7589 trigger a <command>VACUUM</command> operation on any tables based on 7590 the number of inserts. 7591 This parameter can only be set in the <filename>postgresql.conf</filename> 7592 file or on the server command line; 7593 but the setting can be overridden for individual tables by 7594 changing table storage parameters. 7595 </para> 7596 </listitem> 7597 </varlistentry> 7598 7599 <varlistentry id="guc-autovacuum-analyze-threshold" xreflabel="autovacuum_analyze_threshold"> 7600 <term><varname>autovacuum_analyze_threshold</varname> (<type>integer</type>) 7601 <indexterm> 7602 <primary><varname>autovacuum_analyze_threshold</varname></primary> 7603 <secondary>configuration parameter</secondary> 7604 </indexterm> 7605 </term> 7606 <listitem> 7607 <para> 7608 Specifies the minimum number of inserted, updated or deleted tuples 7609 needed to trigger an <command>ANALYZE</command> in any one table. 7610 The default is 50 tuples. 7611 This parameter can only be set in the <filename>postgresql.conf</filename> 7612 file or on the server command line; 7613 but the setting can be overridden for individual tables by 7614 changing table storage parameters. 7615 </para> 7616 </listitem> 7617 </varlistentry> 7618 7619 <varlistentry id="guc-autovacuum-vacuum-scale-factor" xreflabel="autovacuum_vacuum_scale_factor"> 7620 <term><varname>autovacuum_vacuum_scale_factor</varname> (<type>floating point</type>) 7621 <indexterm> 7622 <primary><varname>autovacuum_vacuum_scale_factor</varname></primary> 7623 <secondary>configuration parameter</secondary> 7624 </indexterm> 7625 </term> 7626 <listitem> 7627 <para> 7628 Specifies a fraction of the table size to add to 7629 <varname>autovacuum_vacuum_threshold</varname> 7630 when deciding whether to trigger a <command>VACUUM</command>. 7631 The default is 0.2 (20% of table size). 7632 This parameter can only be set in the <filename>postgresql.conf</filename> 7633 file or on the server command line; 7634 but the setting can be overridden for individual tables by 7635 changing table storage parameters. 7636 </para> 7637 </listitem> 7638 </varlistentry> 7639 7640 <varlistentry id="guc-autovacuum-vacuum-insert-scale-factor" xreflabel="autovacuum_vacuum_insert_scale_factor"> 7641 <term><varname>autovacuum_vacuum_insert_scale_factor</varname> (<type>floating point</type>) 7642 <indexterm> 7643 <primary><varname>autovacuum_vacuum_insert_scale_factor</varname></primary> 7644 <secondary>configuration parameter</secondary> 7645 </indexterm> 7646 </term> 7647 <listitem> 7648 <para> 7649 Specifies a fraction of the table size to add to 7650 <varname>autovacuum_vacuum_insert_threshold</varname> 7651 when deciding whether to trigger a <command>VACUUM</command>. 7652 The default is 0.2 (20% of table size). 7653 This parameter can only be set in the <filename>postgresql.conf</filename> 7654 file or on the server command line; 7655 but the setting can be overridden for individual tables by 7656 changing table storage parameters. 7657 </para> 7658 </listitem> 7659 </varlistentry> 7660 7661 <varlistentry id="guc-autovacuum-analyze-scale-factor" xreflabel="autovacuum_analyze_scale_factor"> 7662 <term><varname>autovacuum_analyze_scale_factor</varname> (<type>floating point</type>) 7663 <indexterm> 7664 <primary><varname>autovacuum_analyze_scale_factor</varname></primary> 7665 <secondary>configuration parameter</secondary> 7666 </indexterm> 7667 </term> 7668 <listitem> 7669 <para> 7670 Specifies a fraction of the table size to add to 7671 <varname>autovacuum_analyze_threshold</varname> 7672 when deciding whether to trigger an <command>ANALYZE</command>. 7673 The default is 0.1 (10% of table size). 7674 This parameter can only be set in the <filename>postgresql.conf</filename> 7675 file or on the server command line; 7676 but the setting can be overridden for individual tables by 7677 changing table storage parameters. 7678 </para> 7679 </listitem> 7680 </varlistentry> 7681 7682 <varlistentry id="guc-autovacuum-freeze-max-age" xreflabel="autovacuum_freeze_max_age"> 7683 <term><varname>autovacuum_freeze_max_age</varname> (<type>integer</type>) 7684 <indexterm> 7685 <primary><varname>autovacuum_freeze_max_age</varname></primary> 7686 <secondary>configuration parameter</secondary> 7687 </indexterm> 7688 </term> 7689 <listitem> 7690 <para> 7691 Specifies the maximum age (in transactions) that a table's 7692 <structname>pg_class</structname>.<structfield>relfrozenxid</structfield> field can 7693 attain before a <command>VACUUM</command> operation is forced 7694 to prevent transaction ID wraparound within the table. 7695 Note that the system will launch autovacuum processes to 7696 prevent wraparound even when autovacuum is otherwise disabled. 7697 </para> 7698 7699 <para> 7700 Vacuum also allows removal of old files from the 7701 <filename>pg_xact</filename> subdirectory, which is why the default 7702 is a relatively low 200 million transactions. 7703 This parameter can only be set at server start, but the setting 7704 can be reduced for individual tables by 7705 changing table storage parameters. 7706 For more information see <xref linkend="vacuum-for-wraparound"/>. 7707 </para> 7708 </listitem> 7709 </varlistentry> 7710 7711 <varlistentry id="guc-autovacuum-multixact-freeze-max-age" xreflabel="autovacuum_multixact_freeze_max_age"> 7712 <term><varname>autovacuum_multixact_freeze_max_age</varname> (<type>integer</type>) 7713 <indexterm> 7714 <primary><varname>autovacuum_multixact_freeze_max_age</varname></primary> 7715 <secondary>configuration parameter</secondary> 7716 </indexterm> 7717 </term> 7718 <listitem> 7719 <para> 7720 Specifies the maximum age (in multixacts) that a table's 7721 <structname>pg_class</structname>.<structfield>relminmxid</structfield> field can 7722 attain before a <command>VACUUM</command> operation is forced to 7723 prevent multixact ID wraparound within the table. 7724 Note that the system will launch autovacuum processes to 7725 prevent wraparound even when autovacuum is otherwise disabled. 7726 </para> 7727 7728 <para> 7729 Vacuuming multixacts also allows removal of old files from the 7730 <filename>pg_multixact/members</filename> and <filename>pg_multixact/offsets</filename> 7731 subdirectories, which is why the default is a relatively low 7732 400 million multixacts. 7733 This parameter can only be set at server start, but the setting can 7734 be reduced for individual tables by changing table storage parameters. 7735 For more information see <xref linkend="vacuum-for-multixact-wraparound"/>. 7736 </para> 7737 </listitem> 7738 </varlistentry> 7739 7740 <varlistentry id="guc-autovacuum-vacuum-cost-delay" xreflabel="autovacuum_vacuum_cost_delay"> 7741 <term><varname>autovacuum_vacuum_cost_delay</varname> (<type>floating point</type>) 7742 <indexterm> 7743 <primary><varname>autovacuum_vacuum_cost_delay</varname></primary> 7744 <secondary>configuration parameter</secondary> 7745 </indexterm> 7746 </term> 7747 <listitem> 7748 <para> 7749 Specifies the cost delay value that will be used in automatic 7750 <command>VACUUM</command> operations. If -1 is specified, the regular 7751 <xref linkend="guc-vacuum-cost-delay"/> value will be used. 7752 If this value is specified without units, it is taken as milliseconds. 7753 The default value is 2 milliseconds. 7754 This parameter can only be set in the <filename>postgresql.conf</filename> 7755 file or on the server command line; 7756 but the setting can be overridden for individual tables by 7757 changing table storage parameters. 7758 </para> 7759 </listitem> 7760 </varlistentry> 7761 7762 <varlistentry id="guc-autovacuum-vacuum-cost-limit" xreflabel="autovacuum_vacuum_cost_limit"> 7763 <term><varname>autovacuum_vacuum_cost_limit</varname> (<type>integer</type>) 7764 <indexterm> 7765 <primary><varname>autovacuum_vacuum_cost_limit</varname></primary> 7766 <secondary>configuration parameter</secondary> 7767 </indexterm> 7768 </term> 7769 <listitem> 7770 <para> 7771 Specifies the cost limit value that will be used in automatic 7772 <command>VACUUM</command> operations. If -1 is specified (which is the 7773 default), the regular 7774 <xref linkend="guc-vacuum-cost-limit"/> value will be used. Note that 7775 the value is distributed proportionally among the running autovacuum 7776 workers, if there is more than one, so that the sum of the limits for 7777 each worker does not exceed the value of this variable. 7778 This parameter can only be set in the <filename>postgresql.conf</filename> 7779 file or on the server command line; 7780 but the setting can be overridden for individual tables by 7781 changing table storage parameters. 7782 </para> 7783 </listitem> 7784 </varlistentry> 7785 7786 </variablelist> 7787 </sect1> 7788 7789 <sect1 id="runtime-config-client"> 7790 <title>Client Connection Defaults</title> 7791 7792 <sect2 id="runtime-config-client-statement"> 7793 <title>Statement Behavior</title> 7794 <variablelist> 7795 7796 <varlistentry id="guc-client-min-messages" xreflabel="client_min_messages"> 7797 <term><varname>client_min_messages</varname> (<type>enum</type>) 7798 <indexterm> 7799 <primary><varname>client_min_messages</varname> configuration parameter</primary> 7800 </indexterm> 7801 </term> 7802 <listitem> 7803 <para> 7804 Controls which 7805 <link linkend="runtime-config-severity-levels">message levels</link> 7806 are sent to the client. 7807 Valid values are <literal>DEBUG5</literal>, 7808 <literal>DEBUG4</literal>, <literal>DEBUG3</literal>, <literal>DEBUG2</literal>, 7809 <literal>DEBUG1</literal>, <literal>LOG</literal>, <literal>NOTICE</literal>, 7810 <literal>WARNING</literal>, and <literal>ERROR</literal>. 7811 Each level includes all the levels that follow it. The later the level, 7812 the fewer messages are sent. The default is 7813 <literal>NOTICE</literal>. Note that <literal>LOG</literal> has a different 7814 rank here than in <xref linkend="guc-log-min-messages"/>. 7815 </para> 7816 <para> 7817 <literal>INFO</literal> level messages are always sent to the client. 7818 </para> 7819 </listitem> 7820 </varlistentry> 7821 7822 <varlistentry id="guc-search-path" xreflabel="search_path"> 7823 <term><varname>search_path</varname> (<type>string</type>) 7824 <indexterm> 7825 <primary><varname>search_path</varname> configuration parameter</primary> 7826 </indexterm> 7827 <indexterm><primary>path</primary><secondary>for schemas</secondary></indexterm> 7828 </term> 7829 <listitem> 7830 <para> 7831 This variable specifies the order in which schemas are searched 7832 when an object (table, data type, function, etc.) is referenced by a 7833 simple name with no schema specified. When there are objects of 7834 identical names in different schemas, the one found first 7835 in the search path is used. An object that is not in any of the 7836 schemas in the search path can only be referenced by specifying 7837 its containing schema with a qualified (dotted) name. 7838 </para> 7839 7840 <para> 7841 The value for <varname>search_path</varname> must be a comma-separated 7842 list of schema names. Any name that is not an existing schema, or is 7843 a schema for which the user does not have <literal>USAGE</literal> 7844 permission, is silently ignored. 7845 </para> 7846 7847 <para> 7848 If one of the list items is the special name 7849 <literal>$user</literal>, then the schema having the name returned by 7850 <function>CURRENT_USER</function> is substituted, if there is such a schema 7851 and the user has <literal>USAGE</literal> permission for it. 7852 (If not, <literal>$user</literal> is ignored.) 7853 </para> 7854 7855 <para> 7856 The system catalog schema, <literal>pg_catalog</literal>, is always 7857 searched, whether it is mentioned in the path or not. If it is 7858 mentioned in the path then it will be searched in the specified 7859 order. If <literal>pg_catalog</literal> is not in the path then it will 7860 be searched <emphasis>before</emphasis> searching any of the path items. 7861 </para> 7862 7863 <!-- To further split hairs, funcname('foo') does not use the temporary 7864 schema, even when it considers typname='funcname'. This paragraph 7865 refers to function names in a loose sense, "pg_proc.proname or 7866 func_name grammar production". --> 7867 <para> 7868 Likewise, the current session's temporary-table schema, 7869 <literal>pg_temp_<replaceable>nnn</replaceable></literal>, is always searched if it 7870 exists. It can be explicitly listed in the path by using the 7871 alias <literal>pg_temp</literal><indexterm><primary>pg_temp</primary></indexterm>. If it is not listed in the path then 7872 it is searched first (even before <literal>pg_catalog</literal>). However, 7873 the temporary schema is only searched for relation (table, view, 7874 sequence, etc) and data type names. It is never searched for 7875 function or operator names. 7876 </para> 7877 7878 <para> 7879 When objects are created without specifying a particular target 7880 schema, they will be placed in the first valid schema named in 7881 <varname>search_path</varname>. An error is reported if the search 7882 path is empty. 7883 </para> 7884 7885 <para> 7886 The default value for this parameter is 7887 <literal>"$user", public</literal>. 7888 This setting supports shared use of a database (where no users 7889 have private schemas, and all share use of <literal>public</literal>), 7890 private per-user schemas, and combinations of these. Other 7891 effects can be obtained by altering the default search path 7892 setting, either globally or per-user. 7893 </para> 7894 7895 <para> 7896 For more information on schema handling, see 7897 <xref linkend="ddl-schemas"/>. In particular, the default 7898 configuration is suitable only when the database has a single user or 7899 a few mutually-trusting users. 7900 </para> 7901 7902 <para> 7903 The current effective value of the search path can be examined 7904 via the <acronym>SQL</acronym> function 7905 <function>current_schemas</function> 7906 (see <xref linkend="functions-info"/>). 7907 This is not quite the same as 7908 examining the value of <varname>search_path</varname>, since 7909 <function>current_schemas</function> shows how the items 7910 appearing in <varname>search_path</varname> were resolved. 7911 </para> 7912 7913 </listitem> 7914 </varlistentry> 7915 7916 <varlistentry id="guc-row-security" xreflabel="row_security"> 7917 <term><varname>row_security</varname> (<type>boolean</type>) 7918 <indexterm> 7919 <primary><varname>row_security</varname> configuration parameter</primary> 7920 </indexterm> 7921 </term> 7922 <listitem> 7923 <para> 7924 This variable controls whether to raise an error in lieu of applying a 7925 row security policy. When set to <literal>on</literal>, policies apply 7926 normally. When set to <literal>off</literal>, queries fail which would 7927 otherwise apply at least one policy. The default is <literal>on</literal>. 7928 Change to <literal>off</literal> where limited row visibility could cause 7929 incorrect results; for example, <application>pg_dump</application> makes that 7930 change by default. This variable has no effect on roles which bypass 7931 every row security policy, to wit, superusers and roles with 7932 the <literal>BYPASSRLS</literal> attribute. 7933 </para> 7934 7935 <para> 7936 For more information on row security policies, 7937 see <xref linkend="sql-createpolicy"/>. 7938 </para> 7939 </listitem> 7940 </varlistentry> 7941 7942 <varlistentry id="guc-default-table-access-method" xreflabel="default_table_access_method"> 7943 <term><varname>default_table_access_method</varname> (<type>string</type>) 7944 <indexterm> 7945 <primary><varname>default_table_access_method</varname> configuration parameter</primary> 7946 </indexterm> 7947 </term> 7948 <listitem> 7949 <para> 7950 This parameter specifies the default table access method to use when 7951 creating tables or materialized views if the <command>CREATE</command> 7952 command does not explicitly specify an access method, or when 7953 <command>SELECT ... INTO</command> is used, which does not allow to 7954 specify a table access method. The default is <literal>heap</literal>. 7955 </para> 7956 </listitem> 7957 </varlistentry> 7958 7959 <varlistentry id="guc-default-tablespace" xreflabel="default_tablespace"> 7960 <term><varname>default_tablespace</varname> (<type>string</type>) 7961 <indexterm> 7962 <primary><varname>default_tablespace</varname> configuration parameter</primary> 7963 </indexterm> 7964 <indexterm><primary>tablespace</primary><secondary>default</secondary></indexterm> 7965 </term> 7966 <listitem> 7967 <para> 7968 This variable specifies the default tablespace in which to create 7969 objects (tables and indexes) when a <command>CREATE</command> command does 7970 not explicitly specify a tablespace. 7971 </para> 7972 7973 <para> 7974 The value is either the name of a tablespace, or an empty string 7975 to specify using the default tablespace of the current database. 7976 If the value does not match the name of any existing tablespace, 7977 <productname>PostgreSQL</productname> will automatically use the default 7978 tablespace of the current database. If a nondefault tablespace 7979 is specified, the user must have <literal>CREATE</literal> privilege 7980 for it, or creation attempts will fail. 7981 </para> 7982 7983 <para> 7984 This variable is not used for temporary tables; for them, 7985 <xref linkend="guc-temp-tablespaces"/> is consulted instead. 7986 </para> 7987 7988 <para> 7989 This variable is also not used when creating databases. 7990 By default, a new database inherits its tablespace setting from 7991 the template database it is copied from. 7992 </para> 7993 7994 <para> 7995 If this parameter is set to a value other than the empty string 7996 when a partitioned table is created, the partitioned table's 7997 tablespace will be set to that value, which will be used as 7998 the default tablespace for partitions created in the future, 7999 even if <varname>default_tablespace</varname> has changed since then. 8000 </para> 8001 8002 <para> 8003 For more information on tablespaces, 8004 see <xref linkend="manage-ag-tablespaces"/>. 8005 </para> 8006 </listitem> 8007 </varlistentry> 8008 8009 <varlistentry id="guc-temp-tablespaces" xreflabel="temp_tablespaces"> 8010 <term><varname>temp_tablespaces</varname> (<type>string</type>) 8011 <indexterm> 8012 <primary><varname>temp_tablespaces</varname> configuration parameter</primary> 8013 </indexterm> 8014 <indexterm><primary>tablespace</primary><secondary>temporary</secondary></indexterm> 8015 </term> 8016 <listitem> 8017 <para> 8018 This variable specifies tablespaces in which to create temporary 8019 objects (temp tables and indexes on temp tables) when a 8020 <command>CREATE</command> command does not explicitly specify a tablespace. 8021 Temporary files for purposes such as sorting large data sets 8022 are also created in these tablespaces. 8023 </para> 8024 8025 <para> 8026 The value is a list of names of tablespaces. When there is more than 8027 one name in the list, <productname>PostgreSQL</productname> chooses a random 8028 member of the list each time a temporary object is to be created; 8029 except that within a transaction, successively created temporary 8030 objects are placed in successive tablespaces from the list. 8031 If the selected element of the list is an empty string, 8032 <productname>PostgreSQL</productname> will automatically use the default 8033 tablespace of the current database instead. 8034 </para> 8035 8036 <para> 8037 When <varname>temp_tablespaces</varname> is set interactively, specifying a 8038 nonexistent tablespace is an error, as is specifying a tablespace for 8039 which the user does not have <literal>CREATE</literal> privilege. However, 8040 when using a previously set value, nonexistent tablespaces are 8041 ignored, as are tablespaces for which the user lacks 8042 <literal>CREATE</literal> privilege. In particular, this rule applies when 8043 using a value set in <filename>postgresql.conf</filename>. 8044 </para> 8045 8046 <para> 8047 The default value is an empty string, which results in all temporary 8048 objects being created in the default tablespace of the current 8049 database. 8050 </para> 8051 8052 <para> 8053 See also <xref linkend="guc-default-tablespace"/>. 8054 </para> 8055 </listitem> 8056 </varlistentry> 8057 8058 <varlistentry id="guc-check-function-bodies" xreflabel="check_function_bodies"> 8059 <term><varname>check_function_bodies</varname> (<type>boolean</type>) 8060 <indexterm> 8061 <primary><varname>check_function_bodies</varname> configuration parameter</primary> 8062 </indexterm> 8063 </term> 8064 <listitem> 8065 <para> 8066 This parameter is normally on. When set to <literal>off</literal>, it 8067 disables validation of the function body string during <xref 8068 linkend="sql-createfunction"/>. Disabling validation avoids side 8069 effects of the validation process and avoids false positives due 8070 to problems such as forward references. Set this parameter 8071 to <literal>off</literal> before loading functions on behalf of other 8072 users; <application>pg_dump</application> does so automatically. 8073 </para> 8074 </listitem> 8075 </varlistentry> 8076 8077 <varlistentry id="guc-default-transaction-isolation" xreflabel="default_transaction_isolation"> 8078 <term><varname>default_transaction_isolation</varname> (<type>enum</type>) 8079 <indexterm> 8080 <primary>transaction isolation level</primary> 8081 <secondary>setting default</secondary> 8082 </indexterm> 8083 <indexterm> 8084 <primary><varname>default_transaction_isolation</varname> configuration parameter</primary> 8085 </indexterm> 8086 </term> 8087 <listitem> 8088 <para> 8089 Each SQL transaction has an isolation level, which can be 8090 either <quote>read uncommitted</quote>, <quote>read 8091 committed</quote>, <quote>repeatable read</quote>, or 8092 <quote>serializable</quote>. This parameter controls the 8093 default isolation level of each new transaction. The default 8094 is <quote>read committed</quote>. 8095 </para> 8096 8097 <para> 8098 Consult <xref linkend="mvcc"/> and <xref 8099 linkend="sql-set-transaction"/> for more information. 8100 </para> 8101 </listitem> 8102 </varlistentry> 8103 8104 <varlistentry id="guc-default-transaction-read-only" xreflabel="default_transaction_read_only"> 8105 <term><varname>default_transaction_read_only</varname> (<type>boolean</type>) 8106 <indexterm> 8107 <primary>read-only transaction</primary> 8108 <secondary>setting default</secondary> 8109 </indexterm> 8110 <indexterm> 8111 <primary><varname>default_transaction_read_only</varname> configuration parameter</primary> 8112 </indexterm> 8113 </term> 8114 <listitem> 8115 <para> 8116 A read-only SQL transaction cannot alter non-temporary tables. 8117 This parameter controls the default read-only status of each new 8118 transaction. The default is <literal>off</literal> (read/write). 8119 </para> 8120 8121 <para> 8122 Consult <xref linkend="sql-set-transaction"/> for more information. 8123 </para> 8124 </listitem> 8125 </varlistentry> 8126 8127 <varlistentry id="guc-default-transaction-deferrable" xreflabel="default_transaction_deferrable"> 8128 <term><varname>default_transaction_deferrable</varname> (<type>boolean</type>) 8129 <indexterm> 8130 <primary>deferrable transaction</primary> 8131 <secondary>setting default</secondary> 8132 </indexterm> 8133 <indexterm> 8134 <primary><varname>default_transaction_deferrable</varname> configuration parameter</primary> 8135 </indexterm> 8136 </term> 8137 <listitem> 8138 <para> 8139 When running at the <literal>serializable</literal> isolation level, 8140 a deferrable read-only SQL transaction may be delayed before 8141 it is allowed to proceed. However, once it begins executing 8142 it does not incur any of the overhead required to ensure 8143 serializability; so serialization code will have no reason to 8144 force it to abort because of concurrent updates, making this 8145 option suitable for long-running read-only transactions. 8146 </para> 8147 8148 <para> 8149 This parameter controls the default deferrable status of each 8150 new transaction. It currently has no effect on read-write 8151 transactions or those operating at isolation levels lower 8152 than <literal>serializable</literal>. The default is <literal>off</literal>. 8153 </para> 8154 8155 <para> 8156 Consult <xref linkend="sql-set-transaction"/> for more information. 8157 </para> 8158 </listitem> 8159 </varlistentry> 8160 8161 <varlistentry id="guc-transaction-isolation" xreflabel="transaction_isolation"> 8162 <term><varname>transaction_isolation</varname> (<type>enum</type>) 8163 <indexterm> 8164 <primary>transaction isolation level</primary> 8165 </indexterm> 8166 <indexterm> 8167 <primary><varname>transaction_isolation</varname> configuration parameter</primary> 8168 </indexterm> 8169 </term> 8170 <listitem> 8171 <para> 8172 This parameter reflects the current transaction's isolation level. 8173 At the beginning of each transaction, it is set to the current value 8174 of <xref linkend="guc-default-transaction-isolation"/>. 8175 Any subsequent attempt to change it is equivalent to a <xref 8176 linkend="sql-set-transaction"/> command. 8177 </para> 8178 </listitem> 8179 </varlistentry> 8180 8181 <varlistentry id="guc-transaction-read-only" xreflabel="transaction_read_only"> 8182 <term><varname>transaction_read_only</varname> (<type>boolean</type>) 8183 <indexterm> 8184 <primary>read-only transaction</primary> 8185 </indexterm> 8186 <indexterm> 8187 <primary><varname>transaction_read_only</varname> configuration parameter</primary> 8188 </indexterm> 8189 </term> 8190 <listitem> 8191 <para> 8192 This parameter reflects the current transaction's read-only status. 8193 At the beginning of each transaction, it is set to the current value 8194 of <xref linkend="guc-default-transaction-read-only"/>. 8195 Any subsequent attempt to change it is equivalent to a <xref 8196 linkend="sql-set-transaction"/> command. 8197 </para> 8198 </listitem> 8199 </varlistentry> 8200 8201 <varlistentry id="guc-transaction-deferrable" xreflabel="transaction_deferrable"> 8202 <term><varname>transaction_deferrable</varname> (<type>boolean</type>) 8203 <indexterm> 8204 <primary>deferrable transaction</primary> 8205 </indexterm> 8206 <indexterm> 8207 <primary><varname>transaction_deferrable</varname> configuration parameter</primary> 8208 </indexterm> 8209 </term> 8210 <listitem> 8211 <para> 8212 This parameter reflects the current transaction's deferrability status. 8213 At the beginning of each transaction, it is set to the current value 8214 of <xref linkend="guc-default-transaction-deferrable"/>. 8215 Any subsequent attempt to change it is equivalent to a <xref 8216 linkend="sql-set-transaction"/> command. 8217 </para> 8218 </listitem> 8219 </varlistentry> 8220 8221 8222 <varlistentry id="guc-session-replication-role" xreflabel="session_replication_role"> 8223 <term><varname>session_replication_role</varname> (<type>enum</type>) 8224 <indexterm> 8225 <primary><varname>session_replication_role</varname> configuration parameter</primary> 8226 </indexterm> 8227 </term> 8228 <listitem> 8229 <para> 8230 Controls firing of replication-related triggers and rules for the 8231 current session. Setting this variable requires 8232 superuser privilege and results in discarding any previously cached 8233 query plans. Possible values are <literal>origin</literal> (the default), 8234 <literal>replica</literal> and <literal>local</literal>. 8235 </para> 8236 8237 <para> 8238 The intended use of this setting is that logical replication systems 8239 set it to <literal>replica</literal> when they are applying replicated 8240 changes. The effect of that will be that triggers and rules (that 8241 have not been altered from their default configuration) will not fire 8242 on the replica. See the <xref linkend="sql-altertable"/> clauses 8243 <literal>ENABLE TRIGGER</literal> and <literal>ENABLE RULE</literal> 8244 for more information. 8245 </para> 8246 8247 <para> 8248 PostgreSQL treats the settings <literal>origin</literal> and 8249 <literal>local</literal> the same internally. Third-party replication 8250 systems may use these two values for their internal purposes, for 8251 example using <literal>local</literal> to designate a session whose 8252 changes should not be replicated. 8253 </para> 8254 8255 <para> 8256 Since foreign keys are implemented as triggers, setting this parameter 8257 to <literal>replica</literal> also disables all foreign key checks, 8258 which can leave data in an inconsistent state if improperly used. 8259 </para> 8260 </listitem> 8261 </varlistentry> 8262 8263 <varlistentry id="guc-statement-timeout" xreflabel="statement_timeout"> 8264 <term><varname>statement_timeout</varname> (<type>integer</type>) 8265 <indexterm> 8266 <primary><varname>statement_timeout</varname> configuration parameter</primary> 8267 </indexterm> 8268 </term> 8269 <listitem> 8270 <para> 8271 Abort any statement that takes more than the specified amount of time. 8272 If <varname>log_min_error_statement</varname> is set 8273 to <literal>ERROR</literal> or lower, the statement that timed out 8274 will also be logged. 8275 If this value is specified without units, it is taken as milliseconds. 8276 A value of zero (the default) disables the timeout. 8277 </para> 8278 8279 <para> 8280 The timeout is measured from the time a command arrives at the 8281 server until it is completed by the server. If multiple SQL 8282 statements appear in a single simple-Query message, the timeout 8283 is applied to each statement separately. 8284 (<productname>PostgreSQL</productname> versions before 13 usually 8285 treated the timeout as applying to the whole query string.) 8286 In extended query protocol, the timeout starts running when any 8287 query-related message (Parse, Bind, Execute, Describe) arrives, and 8288 it is canceled by completion of an Execute or Sync message. 8289 </para> 8290 8291 <para> 8292 Setting <varname>statement_timeout</varname> in 8293 <filename>postgresql.conf</filename> is not recommended because it would 8294 affect all sessions. 8295 </para> 8296 </listitem> 8297 </varlistentry> 8298 8299 <varlistentry id="guc-lock-timeout" xreflabel="lock_timeout"> 8300 <term><varname>lock_timeout</varname> (<type>integer</type>) 8301 <indexterm> 8302 <primary><varname>lock_timeout</varname> configuration parameter</primary> 8303 </indexterm> 8304 </term> 8305 <listitem> 8306 <para> 8307 Abort any statement that waits longer than the specified amount of 8308 time while attempting to acquire a lock on a table, index, 8309 row, or other database object. The time limit applies separately to 8310 each lock acquisition attempt. The limit applies both to explicit 8311 locking requests (such as <command>LOCK TABLE</command>, or <command>SELECT 8312 FOR UPDATE</command> without <literal>NOWAIT</literal>) and to implicitly-acquired 8313 locks. 8314 If this value is specified without units, it is taken as milliseconds. 8315 A value of zero (the default) disables the timeout. 8316 </para> 8317 8318 <para> 8319 Unlike <varname>statement_timeout</varname>, this timeout can only occur 8320 while waiting for locks. Note that if <varname>statement_timeout</varname> 8321 is nonzero, it is rather pointless to set <varname>lock_timeout</varname> to 8322 the same or larger value, since the statement timeout would always 8323 trigger first. If <varname>log_min_error_statement</varname> is set to 8324 <literal>ERROR</literal> or lower, the statement that timed out will be 8325 logged. 8326 </para> 8327 8328 <para> 8329 Setting <varname>lock_timeout</varname> in 8330 <filename>postgresql.conf</filename> is not recommended because it would 8331 affect all sessions. 8332 </para> 8333 </listitem> 8334 </varlistentry> 8335 8336 <varlistentry id="guc-idle-in-transaction-session-timeout" xreflabel="idle_in_transaction_session_timeout"> 8337 <term><varname>idle_in_transaction_session_timeout</varname> (<type>integer</type>) 8338 <indexterm> 8339 <primary><varname>idle_in_transaction_session_timeout</varname> configuration parameter</primary> 8340 </indexterm> 8341 </term> 8342 <listitem> 8343 <para> 8344 Terminate any session with an open transaction that has been idle for 8345 longer than the specified amount of time. This allows any 8346 locks held by that session to be released and the connection slot to be reused; 8347 it also allows tuples visible only to this transaction to be vacuumed. See 8348 <xref linkend="routine-vacuuming"/> for more details about this. 8349 </para> 8350 <para> 8351 If this value is specified without units, it is taken as milliseconds. 8352 A value of zero (the default) disables the timeout. 8353 </para> 8354 </listitem> 8355 </varlistentry> 8356 8357 <varlistentry id="guc-vacuum-freeze-table-age" xreflabel="vacuum_freeze_table_age"> 8358 <term><varname>vacuum_freeze_table_age</varname> (<type>integer</type>) 8359 <indexterm> 8360 <primary><varname>vacuum_freeze_table_age</varname> configuration parameter</primary> 8361 </indexterm> 8362 </term> 8363 <listitem> 8364 <para> 8365 <command>VACUUM</command> performs an aggressive scan if the table's 8366 <structname>pg_class</structname>.<structfield>relfrozenxid</structfield> field has reached 8367 the age specified by this setting. An aggressive scan differs from 8368 a regular <command>VACUUM</command> in that it visits every page that might 8369 contain unfrozen XIDs or MXIDs, not just those that might contain dead 8370 tuples. The default is 150 million transactions. Although users can 8371 set this value anywhere from zero to two billion, <command>VACUUM</command> 8372 will silently limit the effective value to 95% of 8373 <xref linkend="guc-autovacuum-freeze-max-age"/>, so that a 8374 periodic manual <command>VACUUM</command> has a chance to run before an 8375 anti-wraparound autovacuum is launched for the table. For more 8376 information see 8377 <xref linkend="vacuum-for-wraparound"/>. 8378 </para> 8379 </listitem> 8380 </varlistentry> 8381 8382 <varlistentry id="guc-vacuum-freeze-min-age" xreflabel="vacuum_freeze_min_age"> 8383 <term><varname>vacuum_freeze_min_age</varname> (<type>integer</type>) 8384 <indexterm> 8385 <primary><varname>vacuum_freeze_min_age</varname> configuration parameter</primary> 8386 </indexterm> 8387 </term> 8388 <listitem> 8389 <para> 8390 Specifies the cutoff age (in transactions) that <command>VACUUM</command> 8391 should use to decide whether to freeze row versions 8392 while scanning a table. 8393 The default is 50 million transactions. Although 8394 users can set this value anywhere from zero to one billion, 8395 <command>VACUUM</command> will silently limit the effective value to half 8396 the value of <xref linkend="guc-autovacuum-freeze-max-age"/>, so 8397 that there is not an unreasonably short time between forced 8398 autovacuums. For more information see <xref 8399 linkend="vacuum-for-wraparound"/>. 8400 </para> 8401 </listitem> 8402 </varlistentry> 8403 8404 <varlistentry id="guc-vacuum-multixact-freeze-table-age" xreflabel="vacuum_multixact_freeze_table_age"> 8405 <term><varname>vacuum_multixact_freeze_table_age</varname> (<type>integer</type>) 8406 <indexterm> 8407 <primary><varname>vacuum_multixact_freeze_table_age</varname> configuration parameter</primary> 8408 </indexterm> 8409 </term> 8410 <listitem> 8411 <para> 8412 <command>VACUUM</command> performs an aggressive scan if the table's 8413 <structname>pg_class</structname>.<structfield>relminmxid</structfield> field has reached 8414 the age specified by this setting. An aggressive scan differs from 8415 a regular <command>VACUUM</command> in that it visits every page that might 8416 contain unfrozen XIDs or MXIDs, not just those that might contain dead 8417 tuples. The default is 150 million multixacts. 8418 Although users can set this value anywhere from zero to two billion, 8419 <command>VACUUM</command> will silently limit the effective value to 95% of 8420 <xref linkend="guc-autovacuum-multixact-freeze-max-age"/>, so that a 8421 periodic manual <command>VACUUM</command> has a chance to run before an 8422 anti-wraparound is launched for the table. 8423 For more information see <xref linkend="vacuum-for-multixact-wraparound"/>. 8424 </para> 8425 </listitem> 8426 </varlistentry> 8427 8428 <varlistentry id="guc-vacuum-multixact-freeze-min-age" xreflabel="vacuum_multixact_freeze_min_age"> 8429 <term><varname>vacuum_multixact_freeze_min_age</varname> (<type>integer</type>) 8430 <indexterm> 8431 <primary><varname>vacuum_multixact_freeze_min_age</varname> configuration parameter</primary> 8432 </indexterm> 8433 </term> 8434 <listitem> 8435 <para> 8436 Specifies the cutoff age (in multixacts) that <command>VACUUM</command> 8437 should use to decide whether to replace multixact IDs with a newer 8438 transaction ID or multixact ID while scanning a table. The default 8439 is 5 million multixacts. 8440 Although users can set this value anywhere from zero to one billion, 8441 <command>VACUUM</command> will silently limit the effective value to half 8442 the value of <xref linkend="guc-autovacuum-multixact-freeze-max-age"/>, 8443 so that there is not an unreasonably short time between forced 8444 autovacuums. 8445 For more information see <xref linkend="vacuum-for-multixact-wraparound"/>. 8446 </para> 8447 </listitem> 8448 </varlistentry> 8449 8450 <varlistentry id="guc-bytea-output" xreflabel="bytea_output"> 8451 <term><varname>bytea_output</varname> (<type>enum</type>) 8452 <indexterm> 8453 <primary><varname>bytea_output</varname> configuration parameter</primary> 8454 </indexterm> 8455 </term> 8456 <listitem> 8457 <para> 8458 Sets the output format for values of type <type>bytea</type>. 8459 Valid values are <literal>hex</literal> (the default) 8460 and <literal>escape</literal> (the traditional PostgreSQL 8461 format). See <xref linkend="datatype-binary"/> for more 8462 information. The <type>bytea</type> type always 8463 accepts both formats on input, regardless of this setting. 8464 </para> 8465 </listitem> 8466 </varlistentry> 8467 8468 <varlistentry id="guc-xmlbinary" xreflabel="xmlbinary"> 8469 <term><varname>xmlbinary</varname> (<type>enum</type>) 8470 <indexterm> 8471 <primary><varname>xmlbinary</varname> configuration parameter</primary> 8472 </indexterm> 8473 </term> 8474 <listitem> 8475 <para> 8476 Sets how binary values are to be encoded in XML. This applies 8477 for example when <type>bytea</type> values are converted to 8478 XML by the functions <function>xmlelement</function> or 8479 <function>xmlforest</function>. Possible values are 8480 <literal>base64</literal> and <literal>hex</literal>, which 8481 are both defined in the XML Schema standard. The default is 8482 <literal>base64</literal>. For further information about 8483 XML-related functions, see <xref linkend="functions-xml"/>. 8484 </para> 8485 8486 <para> 8487 The actual choice here is mostly a matter of taste, 8488 constrained only by possible restrictions in client 8489 applications. Both methods support all possible values, 8490 although the hex encoding will be somewhat larger than the 8491 base64 encoding. 8492 </para> 8493 </listitem> 8494 </varlistentry> 8495 8496 <varlistentry id="guc-xmloption" xreflabel="xmloption"> 8497 <term><varname>xmloption</varname> (<type>enum</type>) 8498 <indexterm> 8499 <primary><varname>xmloption</varname> configuration parameter</primary> 8500 </indexterm> 8501 <indexterm> 8502 <primary><varname>SET XML OPTION</varname></primary> 8503 </indexterm> 8504 <indexterm> 8505 <primary>XML option</primary> 8506 </indexterm> 8507 </term> 8508 <listitem> 8509 <para> 8510 Sets whether <literal>DOCUMENT</literal> or 8511 <literal>CONTENT</literal> is implicit when converting between 8512 XML and character string values. See <xref 8513 linkend="datatype-xml"/> for a description of this. Valid 8514 values are <literal>DOCUMENT</literal> and 8515 <literal>CONTENT</literal>. The default is 8516 <literal>CONTENT</literal>. 8517 </para> 8518 8519 <para> 8520 According to the SQL standard, the command to set this option is 8521<synopsis> 8522SET XML OPTION { DOCUMENT | CONTENT }; 8523</synopsis> 8524 This syntax is also available in PostgreSQL. 8525 </para> 8526 </listitem> 8527 </varlistentry> 8528 8529 <varlistentry id="guc-gin-pending-list-limit" xreflabel="gin_pending_list_limit"> 8530 <term><varname>gin_pending_list_limit</varname> (<type>integer</type>) 8531 <indexterm> 8532 <primary><varname>gin_pending_list_limit</varname></primary> 8533 <secondary>configuration parameter</secondary> 8534 </indexterm> 8535 </term> 8536 <listitem> 8537 <para> 8538 Sets the maximum size of a GIN index's pending list, which is used 8539 when <literal>fastupdate</literal> is enabled. If the list grows 8540 larger than this maximum size, it is cleaned up by moving 8541 the entries in it to the index's main GIN data structure in bulk. 8542 If this value is specified without units, it is taken as kilobytes. 8543 The default is four megabytes (<literal>4MB</literal>). This setting 8544 can be overridden for individual GIN indexes by changing 8545 index storage parameters. 8546 See <xref linkend="gin-fast-update"/> and <xref linkend="gin-tips"/> 8547 for more information. 8548 </para> 8549 </listitem> 8550 </varlistentry> 8551 8552 </variablelist> 8553 </sect2> 8554 <sect2 id="runtime-config-client-format"> 8555 <title>Locale and Formatting</title> 8556 8557 <variablelist> 8558 8559 <varlistentry id="guc-datestyle" xreflabel="DateStyle"> 8560 <term><varname>DateStyle</varname> (<type>string</type>) 8561 <indexterm> 8562 <primary><varname>DateStyle</varname> configuration parameter</primary> 8563 </indexterm> 8564 </term> 8565 <listitem> 8566 <para> 8567 Sets the display format for date and time values, as well as the 8568 rules for interpreting ambiguous date input values. For 8569 historical reasons, this variable contains two independent 8570 components: the output format specification (<literal>ISO</literal>, 8571 <literal>Postgres</literal>, <literal>SQL</literal>, or <literal>German</literal>) 8572 and the input/output specification for year/month/day ordering 8573 (<literal>DMY</literal>, <literal>MDY</literal>, or <literal>YMD</literal>). These 8574 can be set separately or together. The keywords <literal>Euro</literal> 8575 and <literal>European</literal> are synonyms for <literal>DMY</literal>; the 8576 keywords <literal>US</literal>, <literal>NonEuro</literal>, and 8577 <literal>NonEuropean</literal> are synonyms for <literal>MDY</literal>. See 8578 <xref linkend="datatype-datetime"/> for more information. The 8579 built-in default is <literal>ISO, MDY</literal>, but 8580 <application>initdb</application> will initialize the 8581 configuration file with a setting that corresponds to the 8582 behavior of the chosen <varname>lc_time</varname> locale. 8583 </para> 8584 </listitem> 8585 </varlistentry> 8586 8587 <varlistentry id="guc-intervalstyle" xreflabel="IntervalStyle"> 8588 <term><varname>IntervalStyle</varname> (<type>enum</type>) 8589 <indexterm> 8590 <primary><varname>IntervalStyle</varname> configuration parameter</primary> 8591 </indexterm> 8592 </term> 8593 <listitem> 8594 <para> 8595 Sets the display format for interval values. 8596 The value <literal>sql_standard</literal> will produce 8597 output matching <acronym>SQL</acronym> standard interval literals. 8598 The value <literal>postgres</literal> (which is the default) will produce 8599 output matching <productname>PostgreSQL</productname> releases prior to 8.4 8600 when the <xref linkend="guc-datestyle"/> 8601 parameter was set to <literal>ISO</literal>. 8602 The value <literal>postgres_verbose</literal> will produce output 8603 matching <productname>PostgreSQL</productname> releases prior to 8.4 8604 when the <varname>DateStyle</varname> 8605 parameter was set to non-<literal>ISO</literal> output. 8606 The value <literal>iso_8601</literal> will produce output matching the time 8607 interval <quote>format with designators</quote> defined in section 8608 4.4.3.2 of ISO 8601. 8609 </para> 8610 <para> 8611 The <varname>IntervalStyle</varname> parameter also affects the 8612 interpretation of ambiguous interval input. See 8613 <xref linkend="datatype-interval-input"/> for more information. 8614 </para> 8615 </listitem> 8616 </varlistentry> 8617 8618 <varlistentry id="guc-timezone" xreflabel="TimeZone"> 8619 <term><varname>TimeZone</varname> (<type>string</type>) 8620 <indexterm> 8621 <primary><varname>TimeZone</varname> configuration parameter</primary> 8622 </indexterm> 8623 <indexterm><primary>time zone</primary></indexterm> 8624 </term> 8625 <listitem> 8626 <para> 8627 Sets the time zone for displaying and interpreting time stamps. 8628 The built-in default is <literal>GMT</literal>, but that is typically 8629 overridden in <filename>postgresql.conf</filename>; <application>initdb</application> 8630 will install a setting there corresponding to its system environment. 8631 See <xref linkend="datatype-timezones"/> for more information. 8632 </para> 8633 </listitem> 8634 </varlistentry> 8635 8636 <varlistentry id="guc-timezone-abbreviations" xreflabel="timezone_abbreviations"> 8637 <term><varname>timezone_abbreviations</varname> (<type>string</type>) 8638 <indexterm> 8639 <primary><varname>timezone_abbreviations</varname> configuration parameter</primary> 8640 </indexterm> 8641 <indexterm><primary>time zone names</primary></indexterm> 8642 </term> 8643 <listitem> 8644 <para> 8645 Sets the collection of time zone abbreviations that will be accepted 8646 by the server for datetime input. The default is <literal>'Default'</literal>, 8647 which is a collection that works in most of the world; there are 8648 also <literal>'Australia'</literal> and <literal>'India'</literal>, 8649 and other collections can be defined for a particular installation. 8650 See <xref linkend="datetime-config-files"/> for more information. 8651 </para> 8652 </listitem> 8653 </varlistentry> 8654 8655 <varlistentry id="guc-extra-float-digits" xreflabel="extra_float_digits"> 8656 <term><varname>extra_float_digits</varname> (<type>integer</type>) 8657 <indexterm> 8658 <primary>significant digits</primary> 8659 </indexterm> 8660 <indexterm> 8661 <primary>floating-point</primary> 8662 <secondary>display</secondary> 8663 </indexterm> 8664 <indexterm> 8665 <primary><varname>extra_float_digits</varname> configuration parameter</primary> 8666 </indexterm> 8667 </term> 8668 <listitem> 8669 <para> 8670 This parameter adjusts the number of digits used for textual output of 8671 floating-point values, including <type>float4</type>, <type>float8</type>, 8672 and geometric data types. 8673 </para> 8674 <para> 8675 If the value is 1 (the default) or above, float values are output in 8676 shortest-precise format; see <xref linkend="datatype-float"/>. The 8677 actual number of digits generated depends only on the value being 8678 output, not on the value of this parameter. At most 17 digits are 8679 required for <type>float8</type> values, and 9 for <type>float4</type> 8680 values. This format is both fast and precise, preserving the original 8681 binary float value exactly when correctly read. For historical 8682 compatibility, values up to 3 are permitted. 8683 </para> 8684 <para> 8685 If the value is zero or negative, then the output is rounded to a 8686 given decimal precision. The precision used is the standard number of 8687 digits for the type (<literal>FLT_DIG</literal> 8688 or <literal>DBL_DIG</literal> as appropriate) reduced according to the 8689 value of this parameter. (For example, specifying -1 will cause 8690 <type>float4</type> values to be output rounded to 5 significant 8691 digits, and <type>float8</type> values 8692 rounded to 14 digits.) This format is slower and does not preserve all 8693 the bits of the binary float value, but may be more human-readable. 8694 </para> 8695 <note> 8696 <para> 8697 The meaning of this parameter, and its default value, changed 8698 in <productname>PostgreSQL</productname> 12; 8699 see <xref linkend="datatype-float"/> for further discussion. 8700 </para> 8701 </note> 8702 </listitem> 8703 </varlistentry> 8704 8705 <varlistentry id="guc-client-encoding" xreflabel="client_encoding"> 8706 <term><varname>client_encoding</varname> (<type>string</type>) 8707 <indexterm> 8708 <primary><varname>client_encoding</varname> configuration parameter</primary> 8709 </indexterm> 8710 <indexterm><primary>character set</primary></indexterm> 8711 </term> 8712 <listitem> 8713 <para> 8714 Sets the client-side encoding (character set). 8715 The default is to use the database encoding. 8716 The character sets supported by the <productname>PostgreSQL</productname> 8717 server are described in <xref linkend="multibyte-charset-supported"/>. 8718 </para> 8719 </listitem> 8720 </varlistentry> 8721 8722 <varlistentry id="guc-lc-messages" xreflabel="lc_messages"> 8723 <term><varname>lc_messages</varname> (<type>string</type>) 8724 <indexterm> 8725 <primary><varname>lc_messages</varname> configuration parameter</primary> 8726 </indexterm> 8727 </term> 8728 <listitem> 8729 <para> 8730 Sets the language in which messages are displayed. Acceptable 8731 values are system-dependent; see <xref linkend="locale"/> for 8732 more information. If this variable is set to the empty string 8733 (which is the default) then the value is inherited from the 8734 execution environment of the server in a system-dependent way. 8735 </para> 8736 8737 <para> 8738 On some systems, this locale category does not exist. Setting 8739 this variable will still work, but there will be no effect. 8740 Also, there is a chance that no translated messages for the 8741 desired language exist. In that case you will continue to see 8742 the English messages. 8743 </para> 8744 8745 <para> 8746 Only superusers can change this setting, because it affects the 8747 messages sent to the server log as well as to the client, and 8748 an improper value might obscure the readability of the server 8749 logs. 8750 </para> 8751 </listitem> 8752 </varlistentry> 8753 8754 <varlistentry id="guc-lc-monetary" xreflabel="lc_monetary"> 8755 <term><varname>lc_monetary</varname> (<type>string</type>) 8756 <indexterm> 8757 <primary><varname>lc_monetary</varname> configuration parameter</primary> 8758 </indexterm> 8759 </term> 8760 <listitem> 8761 <para> 8762 Sets the locale to use for formatting monetary amounts, for 8763 example with the <function>to_char</function> family of 8764 functions. Acceptable values are system-dependent; see <xref 8765 linkend="locale"/> for more information. If this variable is 8766 set to the empty string (which is the default) then the value 8767 is inherited from the execution environment of the server in a 8768 system-dependent way. 8769 </para> 8770 </listitem> 8771 </varlistentry> 8772 8773 <varlistentry id="guc-lc-numeric" xreflabel="lc_numeric"> 8774 <term><varname>lc_numeric</varname> (<type>string</type>) 8775 <indexterm> 8776 <primary><varname>lc_numeric</varname> configuration parameter</primary> 8777 </indexterm> 8778 </term> 8779 <listitem> 8780 <para> 8781 Sets the locale to use for formatting numbers, for example 8782 with the <function>to_char</function> family of 8783 functions. Acceptable values are system-dependent; see <xref 8784 linkend="locale"/> for more information. If this variable is 8785 set to the empty string (which is the default) then the value 8786 is inherited from the execution environment of the server in a 8787 system-dependent way. 8788 </para> 8789 </listitem> 8790 </varlistentry> 8791 8792 <varlistentry id="guc-lc-time" xreflabel="lc_time"> 8793 <term><varname>lc_time</varname> (<type>string</type>) 8794 <indexterm> 8795 <primary><varname>lc_time</varname> configuration parameter</primary> 8796 </indexterm> 8797 </term> 8798 <listitem> 8799 <para> 8800 Sets the locale to use for formatting dates and times, for example 8801 with the <function>to_char</function> family of 8802 functions. Acceptable values are system-dependent; see <xref 8803 linkend="locale"/> for more information. If this variable is 8804 set to the empty string (which is the default) then the value 8805 is inherited from the execution environment of the server in a 8806 system-dependent way. 8807 </para> 8808 </listitem> 8809 </varlistentry> 8810 8811 <varlistentry id="guc-default-text-search-config" xreflabel="default_text_search_config"> 8812 <term><varname>default_text_search_config</varname> (<type>string</type>) 8813 <indexterm> 8814 <primary><varname>default_text_search_config</varname> configuration parameter</primary> 8815 </indexterm> 8816 </term> 8817 <listitem> 8818 <para> 8819 Selects the text search configuration that is used by those variants 8820 of the text search functions that do not have an explicit argument 8821 specifying the configuration. 8822 See <xref linkend="textsearch"/> for further information. 8823 The built-in default is <literal>pg_catalog.simple</literal>, but 8824 <application>initdb</application> will initialize the 8825 configuration file with a setting that corresponds to the 8826 chosen <varname>lc_ctype</varname> locale, if a configuration 8827 matching that locale can be identified. 8828 </para> 8829 </listitem> 8830 </varlistentry> 8831 8832 </variablelist> 8833 8834 </sect2> 8835 8836 <sect2 id="runtime-config-client-preload"> 8837 <title>Shared Library Preloading</title> 8838 8839 <para> 8840 Several settings are available for preloading shared libraries into the 8841 server, in order to load additional functionality or achieve performance 8842 benefits. For example, a setting of 8843 <literal>'$libdir/mylib'</literal> would cause 8844 <literal>mylib.so</literal> (or on some platforms, 8845 <literal>mylib.sl</literal>) to be preloaded from the installation's standard 8846 library directory. The differences between the settings are when they 8847 take effect and what privileges are required to change them. 8848 </para> 8849 8850 <para> 8851 <productname>PostgreSQL</productname> procedural language libraries can 8852 be preloaded in this way, typically by using the 8853 syntax <literal>'$libdir/plXXX'</literal> where 8854 <literal>XXX</literal> is <literal>pgsql</literal>, <literal>perl</literal>, 8855 <literal>tcl</literal>, or <literal>python</literal>. 8856 </para> 8857 8858 <para> 8859 Only shared libraries specifically intended to be used with PostgreSQL 8860 can be loaded this way. Every PostgreSQL-supported library has 8861 a <quote>magic block</quote> that is checked to guarantee compatibility. For 8862 this reason, non-PostgreSQL libraries cannot be loaded in this way. You 8863 might be able to use operating-system facilities such 8864 as <envar>LD_PRELOAD</envar> for that. 8865 </para> 8866 8867 <para> 8868 In general, refer to the documentation of a specific module for the 8869 recommended way to load that module. 8870 </para> 8871 8872 <variablelist> 8873 <varlistentry id="guc-local-preload-libraries" xreflabel="local_preload_libraries"> 8874 <term><varname>local_preload_libraries</varname> (<type>string</type>) 8875 <indexterm> 8876 <primary><varname>local_preload_libraries</varname> configuration parameter</primary> 8877 </indexterm> 8878 <indexterm> 8879 <primary><filename>$libdir/plugins</filename></primary> 8880 </indexterm> 8881 </term> 8882 <listitem> 8883 <para> 8884 This variable specifies one or more shared libraries that are to be 8885 preloaded at connection start. 8886 It contains a comma-separated list of library names, where each name 8887 is interpreted as for the <xref linkend="sql-load"/> command. 8888 Whitespace between entries is ignored; surround a library name with 8889 double quotes if you need to include whitespace or commas in the name. 8890 The parameter value only takes effect at the start of the connection. 8891 Subsequent changes have no effect. If a specified library is not 8892 found, the connection attempt will fail. 8893 </para> 8894 8895 <para> 8896 This option can be set by any user. Because of that, the libraries 8897 that can be loaded are restricted to those appearing in the 8898 <filename>plugins</filename> subdirectory of the installation's 8899 standard library directory. (It is the database administrator's 8900 responsibility to ensure that only <quote>safe</quote> libraries 8901 are installed there.) Entries in <varname>local_preload_libraries</varname> 8902 can specify this directory explicitly, for example 8903 <literal>$libdir/plugins/mylib</literal>, or just specify 8904 the library name — <literal>mylib</literal> would have 8905 the same effect as <literal>$libdir/plugins/mylib</literal>. 8906 </para> 8907 8908 <para> 8909 The intent of this feature is to allow unprivileged users to load 8910 debugging or performance-measurement libraries into specific sessions 8911 without requiring an explicit <command>LOAD</command> command. To that end, 8912 it would be typical to set this parameter using 8913 the <envar>PGOPTIONS</envar> environment variable on the client or by 8914 using 8915 <command>ALTER ROLE SET</command>. 8916 </para> 8917 8918 <para> 8919 However, unless a module is specifically designed to be used in this way by 8920 non-superusers, this is usually not the right setting to use. Look 8921 at <xref linkend="guc-session-preload-libraries"/> instead. 8922 </para> 8923 </listitem> 8924 </varlistentry> 8925 8926 8927 <varlistentry id="guc-session-preload-libraries" xreflabel="session_preload_libraries"> 8928 <term><varname>session_preload_libraries</varname> (<type>string</type>) 8929 <indexterm> 8930 <primary><varname>session_preload_libraries</varname> configuration parameter</primary> 8931 </indexterm> 8932 </term> 8933 <listitem> 8934 <para> 8935 This variable specifies one or more shared libraries that are to be 8936 preloaded at connection start. 8937 It contains a comma-separated list of library names, where each name 8938 is interpreted as for the <xref linkend="sql-load"/> command. 8939 Whitespace between entries is ignored; surround a library name with 8940 double quotes if you need to include whitespace or commas in the name. 8941 The parameter value only takes effect at the start of the connection. 8942 Subsequent changes have no effect. If a specified library is not 8943 found, the connection attempt will fail. 8944 Only superusers can change this setting. 8945 </para> 8946 8947 <para> 8948 The intent of this feature is to allow debugging or 8949 performance-measurement libraries to be loaded into specific sessions 8950 without an explicit 8951 <command>LOAD</command> command being given. For 8952 example, <xref linkend="auto-explain"/> could be enabled for all 8953 sessions under a given user name by setting this parameter 8954 with <command>ALTER ROLE SET</command>. Also, this parameter can be changed 8955 without restarting the server (but changes only take effect when a new 8956 session is started), so it is easier to add new modules this way, even 8957 if they should apply to all sessions. 8958 </para> 8959 8960 <para> 8961 Unlike <xref linkend="guc-shared-preload-libraries"/>, there is no large 8962 performance advantage to loading a library at session start rather than 8963 when it is first used. There is some advantage, however, when 8964 connection pooling is used. 8965 </para> 8966 </listitem> 8967 </varlistentry> 8968 8969 <varlistentry id="guc-shared-preload-libraries" xreflabel="shared_preload_libraries"> 8970 <term><varname>shared_preload_libraries</varname> (<type>string</type>) 8971 <indexterm> 8972 <primary><varname>shared_preload_libraries</varname> configuration parameter</primary> 8973 </indexterm> 8974 </term> 8975 <listitem> 8976 <para> 8977 This variable specifies one or more shared libraries to be preloaded at 8978 server start. 8979 It contains a comma-separated list of library names, where each name 8980 is interpreted as for the <xref linkend="sql-load"/> command. 8981 Whitespace between entries is ignored; surround a library name with 8982 double quotes if you need to include whitespace or commas in the name. 8983 This parameter can only be set at server start. If a specified 8984 library is not found, the server will fail to start. 8985 </para> 8986 8987 <para> 8988 Some libraries need to perform certain operations that can only take 8989 place at postmaster start, such as allocating shared memory, reserving 8990 light-weight locks, or starting background workers. Those libraries 8991 must be loaded at server start through this parameter. See the 8992 documentation of each library for details. 8993 </para> 8994 8995 <para> 8996 Other libraries can also be preloaded. By preloading a shared library, 8997 the library startup time is avoided when the library is first used. 8998 However, the time to start each new server process might increase 8999 slightly, even if that process never uses the library. So this 9000 parameter is recommended only for libraries that will be used in most 9001 sessions. Also, changing this parameter requires a server restart, so 9002 this is not the right setting to use for short-term debugging tasks, 9003 say. Use <xref linkend="guc-session-preload-libraries"/> for that 9004 instead. 9005 </para> 9006 9007 <note> 9008 <para> 9009 On Windows hosts, preloading a library at server start will not reduce 9010 the time required to start each new server process; each server process 9011 will re-load all preload libraries. However, <varname>shared_preload_libraries 9012 </varname> is still useful on Windows hosts for libraries that need to 9013 perform operations at postmaster start time. 9014 </para> 9015 </note> 9016 </listitem> 9017 </varlistentry> 9018 9019 <varlistentry id="guc-jit-provider" xreflabel="jit_provider"> 9020 <term><varname>jit_provider</varname> (<type>string</type>) 9021 <indexterm> 9022 <primary><varname>jit_provider</varname> configuration parameter</primary> 9023 </indexterm> 9024 </term> 9025 <listitem> 9026 <para> 9027 This variable is the name of the JIT provider library to be used 9028 (see <xref linkend="jit-pluggable"/>). 9029 The default is <literal>llvmjit</literal>. 9030 This parameter can only be set at server start. 9031 </para> 9032 9033 <para> 9034 If set to a non-existent library, <acronym>JIT</acronym> will not be 9035 available, but no error will be raised. This allows JIT support to be 9036 installed separately from the main 9037 <productname>PostgreSQL</productname> package. 9038 </para> 9039 </listitem> 9040 </varlistentry> 9041 9042 </variablelist> 9043 </sect2> 9044 9045 <sect2 id="runtime-config-client-other"> 9046 <title>Other Defaults</title> 9047 9048 <variablelist> 9049 9050 <varlistentry id="guc-dynamic-library-path" xreflabel="dynamic_library_path"> 9051 <term><varname>dynamic_library_path</varname> (<type>string</type>) 9052 <indexterm> 9053 <primary><varname>dynamic_library_path</varname> configuration parameter</primary> 9054 </indexterm> 9055 <indexterm><primary>dynamic loading</primary></indexterm> 9056 </term> 9057 <listitem> 9058 <para> 9059 If a dynamically loadable module needs to be opened and the 9060 file name specified in the <command>CREATE FUNCTION</command> or 9061 <command>LOAD</command> command 9062 does not have a directory component (i.e., the 9063 name does not contain a slash), the system will search this 9064 path for the required file. 9065 </para> 9066 9067 <para> 9068 The value for <varname>dynamic_library_path</varname> must be a 9069 list of absolute directory paths separated by colons (or semi-colons 9070 on Windows). If a list element starts 9071 with the special string <literal>$libdir</literal>, the 9072 compiled-in <productname>PostgreSQL</productname> package 9073 library directory is substituted for <literal>$libdir</literal>; this 9074 is where the modules provided by the standard 9075 <productname>PostgreSQL</productname> distribution are installed. 9076 (Use <literal>pg_config --pkglibdir</literal> to find out the name of 9077 this directory.) For example: 9078<programlisting> 9079dynamic_library_path = '/usr/local/lib/postgresql:/home/my_project/lib:$libdir' 9080</programlisting> 9081 or, in a Windows environment: 9082<programlisting> 9083dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir' 9084</programlisting> 9085 </para> 9086 9087 <para> 9088 The default value for this parameter is 9089 <literal>'$libdir'</literal>. If the value is set to an empty 9090 string, the automatic path search is turned off. 9091 </para> 9092 9093 <para> 9094 This parameter can be changed at run time by superusers, but a 9095 setting done that way will only persist until the end of the 9096 client connection, so this method should be reserved for 9097 development purposes. The recommended way to set this parameter 9098 is in the <filename>postgresql.conf</filename> configuration 9099 file. 9100 </para> 9101 </listitem> 9102 </varlistentry> 9103 9104 <varlistentry id="guc-gin-fuzzy-search-limit" xreflabel="gin_fuzzy_search_limit"> 9105 <term><varname>gin_fuzzy_search_limit</varname> (<type>integer</type>) 9106 <indexterm> 9107 <primary><varname>gin_fuzzy_search_limit</varname> configuration parameter</primary> 9108 </indexterm> 9109 </term> 9110 <listitem> 9111 <para> 9112 Soft upper limit of the size of the set returned by GIN index scans. For more 9113 information see <xref linkend="gin-tips"/>. 9114 </para> 9115 </listitem> 9116 </varlistentry> 9117 9118 </variablelist> 9119 </sect2> 9120 </sect1> 9121 9122 <sect1 id="runtime-config-locks"> 9123 <title>Lock Management</title> 9124 9125 <variablelist> 9126 9127 <varlistentry id="guc-deadlock-timeout" xreflabel="deadlock_timeout"> 9128 <term><varname>deadlock_timeout</varname> (<type>integer</type>) 9129 <indexterm> 9130 <primary>deadlock</primary> 9131 <secondary>timeout during</secondary> 9132 </indexterm> 9133 <indexterm> 9134 <primary>timeout</primary> 9135 <secondary>deadlock</secondary> 9136 </indexterm> 9137 <indexterm> 9138 <primary><varname>deadlock_timeout</varname> configuration parameter</primary> 9139 </indexterm> 9140 </term> 9141 <listitem> 9142 <para> 9143 This is the amount of time to wait on a lock 9144 before checking to see if there is a deadlock condition. The 9145 check for deadlock is relatively expensive, so the server doesn't run 9146 it every time it waits for a lock. We optimistically assume 9147 that deadlocks are not common in production applications and 9148 just wait on the lock for a while before checking for a 9149 deadlock. Increasing this value reduces the amount of time 9150 wasted in needless deadlock checks, but slows down reporting of 9151 real deadlock errors. 9152 If this value is specified without units, it is taken as milliseconds. 9153 The default is one second (<literal>1s</literal>), 9154 which is probably about the smallest value you would want in 9155 practice. On a heavily loaded server you might want to raise it. 9156 Ideally the setting should exceed your typical transaction time, 9157 so as to improve the odds that a lock will be released before 9158 the waiter decides to check for deadlock. Only superusers can change 9159 this setting. 9160 </para> 9161 9162 <para> 9163 When <xref linkend="guc-log-lock-waits"/> is set, 9164 this parameter also determines the amount of time to wait before 9165 a log message is issued about the lock wait. If you are trying 9166 to investigate locking delays you might want to set a shorter than 9167 normal <varname>deadlock_timeout</varname>. 9168 </para> 9169 </listitem> 9170 </varlistentry> 9171 9172 <varlistentry id="guc-max-locks-per-transaction" xreflabel="max_locks_per_transaction"> 9173 <term><varname>max_locks_per_transaction</varname> (<type>integer</type>) 9174 <indexterm> 9175 <primary><varname>max_locks_per_transaction</varname> configuration parameter</primary> 9176 </indexterm> 9177 </term> 9178 <listitem> 9179 <para> 9180 The shared lock table tracks locks on 9181 <varname>max_locks_per_transaction</varname> * (<xref 9182 linkend="guc-max-connections"/> + <xref 9183 linkend="guc-max-prepared-transactions"/>) objects (e.g., tables); 9184 hence, no more than this many distinct objects can be locked at 9185 any one time. This parameter controls the average number of object 9186 locks allocated for each transaction; individual transactions 9187 can lock more objects as long as the locks of all transactions 9188 fit in the lock table. This is <emphasis>not</emphasis> the number of 9189 rows that can be locked; that value is unlimited. The default, 9190 64, has historically proven sufficient, but you might need to 9191 raise this value if you have queries that touch many different 9192 tables in a single transaction, e.g., query of a parent table with 9193 many children. This parameter can only be set at server start. 9194 </para> 9195 9196 <para> 9197 When running a standby server, you must set this parameter to the 9198 same or higher value than on the master server. Otherwise, queries 9199 will not be allowed in the standby server. 9200 </para> 9201 </listitem> 9202 </varlistentry> 9203 9204 <varlistentry id="guc-max-pred-locks-per-transaction" xreflabel="max_pred_locks_per_transaction"> 9205 <term><varname>max_pred_locks_per_transaction</varname> (<type>integer</type>) 9206 <indexterm> 9207 <primary><varname>max_pred_locks_per_transaction</varname> configuration parameter</primary> 9208 </indexterm> 9209 </term> 9210 <listitem> 9211 <para> 9212 The shared predicate lock table tracks locks on 9213 <varname>max_pred_locks_per_transaction</varname> * (<xref 9214 linkend="guc-max-connections"/> + <xref 9215 linkend="guc-max-prepared-transactions"/>) objects (e.g., tables); 9216 hence, no more than this many distinct objects can be locked at 9217 any one time. This parameter controls the average number of object 9218 locks allocated for each transaction; individual transactions 9219 can lock more objects as long as the locks of all transactions 9220 fit in the lock table. This is <emphasis>not</emphasis> the number of 9221 rows that can be locked; that value is unlimited. The default, 9222 64, has generally been sufficient in testing, but you might need to 9223 raise this value if you have clients that touch many different 9224 tables in a single serializable transaction. This parameter can 9225 only be set at server start. 9226 </para> 9227 </listitem> 9228 </varlistentry> 9229 9230 <varlistentry id="guc-max-pred-locks-per-relation" xreflabel="max_pred_locks_per_relation"> 9231 <term><varname>max_pred_locks_per_relation</varname> (<type>integer</type>) 9232 <indexterm> 9233 <primary><varname>max_pred_locks_per_relation</varname> configuration parameter</primary> 9234 </indexterm> 9235 </term> 9236 <listitem> 9237 <para> 9238 This controls how many pages or tuples of a single relation can be 9239 predicate-locked before the lock is promoted to covering the whole 9240 relation. Values greater than or equal to zero mean an absolute 9241 limit, while negative values 9242 mean <xref linkend="guc-max-pred-locks-per-transaction"/> divided by 9243 the absolute value of this setting. The default is -2, which keeps 9244 the behavior from previous versions of <productname>PostgreSQL</productname>. 9245 This parameter can only be set in the <filename>postgresql.conf</filename> 9246 file or on the server command line. 9247 </para> 9248 </listitem> 9249 </varlistentry> 9250 9251 <varlistentry id="guc-max-pred-locks-per-page" xreflabel="max_pred_locks_per_page"> 9252 <term><varname>max_pred_locks_per_page</varname> (<type>integer</type>) 9253 <indexterm> 9254 <primary><varname>max_pred_locks_per_page</varname> configuration parameter</primary> 9255 </indexterm> 9256 </term> 9257 <listitem> 9258 <para> 9259 This controls how many rows on a single page can be predicate-locked 9260 before the lock is promoted to covering the whole page. The default 9261 is 2. This parameter can only be set in 9262 the <filename>postgresql.conf</filename> file or on the server command line. 9263 </para> 9264 </listitem> 9265 </varlistentry> 9266 9267 </variablelist> 9268 </sect1> 9269 9270 <sect1 id="runtime-config-compatible"> 9271 <title>Version and Platform Compatibility</title> 9272 9273 <sect2 id="runtime-config-compatible-version"> 9274 <title>Previous PostgreSQL Versions</title> 9275 9276 <variablelist> 9277 9278 <varlistentry id="guc-array-nulls" xreflabel="array_nulls"> 9279 <term><varname>array_nulls</varname> (<type>boolean</type>) 9280 <indexterm> 9281 <primary><varname>array_nulls</varname> configuration parameter</primary> 9282 </indexterm> 9283 </term> 9284 <listitem> 9285 <para> 9286 This controls whether the array input parser recognizes 9287 unquoted <literal>NULL</literal> as specifying a null array element. 9288 By default, this is <literal>on</literal>, allowing array values containing 9289 null values to be entered. However, <productname>PostgreSQL</productname> versions 9290 before 8.2 did not support null values in arrays, and therefore would 9291 treat <literal>NULL</literal> as specifying a normal array element with 9292 the string value <quote>NULL</quote>. For backward compatibility with 9293 applications that require the old behavior, this variable can be 9294 turned <literal>off</literal>. 9295 </para> 9296 9297 <para> 9298 Note that it is possible to create array values containing null values 9299 even when this variable is <literal>off</literal>. 9300 </para> 9301 </listitem> 9302 </varlistentry> 9303 9304 <varlistentry id="guc-backslash-quote" xreflabel="backslash_quote"> 9305 <term><varname>backslash_quote</varname> (<type>enum</type>) 9306 <indexterm><primary>strings</primary><secondary>backslash quotes</secondary></indexterm> 9307 <indexterm> 9308 <primary><varname>backslash_quote</varname> configuration parameter</primary> 9309 </indexterm> 9310 </term> 9311 <listitem> 9312 <para> 9313 This controls whether a quote mark can be represented by 9314 <literal>\'</literal> in a string literal. The preferred, SQL-standard way 9315 to represent a quote mark is by doubling it (<literal>''</literal>) but 9316 <productname>PostgreSQL</productname> has historically also accepted 9317 <literal>\'</literal>. However, use of <literal>\'</literal> creates security risks 9318 because in some client character set encodings, there are multibyte 9319 characters in which the last byte is numerically equivalent to ASCII 9320 <literal>\</literal>. If client-side code does escaping incorrectly then a 9321 SQL-injection attack is possible. This risk can be prevented by 9322 making the server reject queries in which a quote mark appears to be 9323 escaped by a backslash. 9324 The allowed values of <varname>backslash_quote</varname> are 9325 <literal>on</literal> (allow <literal>\'</literal> always), 9326 <literal>off</literal> (reject always), and 9327 <literal>safe_encoding</literal> (allow only if client encoding does not 9328 allow ASCII <literal>\</literal> within a multibyte character). 9329 <literal>safe_encoding</literal> is the default setting. 9330 </para> 9331 9332 <para> 9333 Note that in a standard-conforming string literal, <literal>\</literal> just 9334 means <literal>\</literal> anyway. This parameter only affects the handling of 9335 non-standard-conforming literals, including 9336 escape string syntax (<literal>E'...'</literal>). 9337 </para> 9338 </listitem> 9339 </varlistentry> 9340 9341 <varlistentry id="guc-escape-string-warning" xreflabel="escape_string_warning"> 9342 <term><varname>escape_string_warning</varname> (<type>boolean</type>) 9343 <indexterm><primary>strings</primary><secondary>escape warning</secondary></indexterm> 9344 <indexterm> 9345 <primary><varname>escape_string_warning</varname> configuration parameter</primary> 9346 </indexterm> 9347 </term> 9348 <listitem> 9349 <para> 9350 When on, a warning is issued if a backslash (<literal>\</literal>) 9351 appears in an ordinary string literal (<literal>'...'</literal> 9352 syntax) and <varname>standard_conforming_strings</varname> is off. 9353 The default is <literal>on</literal>. 9354 </para> 9355 <para> 9356 Applications that wish to use backslash as escape should be 9357 modified to use escape string syntax (<literal>E'...'</literal>), 9358 because the default behavior of ordinary strings is now to treat 9359 backslash as an ordinary character, per SQL standard. This variable 9360 can be enabled to help locate code that needs to be changed. 9361 </para> 9362 </listitem> 9363 </varlistentry> 9364 9365 <varlistentry id="guc-lo-compat-privileges" xreflabel="lo_compat_privileges"> 9366 <term><varname>lo_compat_privileges</varname> (<type>boolean</type>) 9367 <indexterm> 9368 <primary><varname>lo_compat_privileges</varname> configuration parameter</primary> 9369 </indexterm> 9370 </term> 9371 <listitem> 9372 <para> 9373 In <productname>PostgreSQL</productname> releases prior to 9.0, large objects 9374 did not have access privileges and were, therefore, always readable 9375 and writable by all users. Setting this variable to <literal>on</literal> 9376 disables the new privilege checks, for compatibility with prior 9377 releases. The default is <literal>off</literal>. 9378 Only superusers can change this setting. 9379 </para> 9380 <para> 9381 Setting this variable does not disable all security checks related to 9382 large objects — only those for which the default behavior has 9383 changed in <productname>PostgreSQL</productname> 9.0. 9384 </para> 9385 </listitem> 9386 </varlistentry> 9387 9388 <varlistentry id="guc-operator-precedence-warning" xreflabel="operator_precedence_warning"> 9389 <term><varname>operator_precedence_warning</varname> (<type>boolean</type>) 9390 <indexterm> 9391 <primary><varname>operator_precedence_warning</varname> configuration parameter</primary> 9392 </indexterm> 9393 </term> 9394 <listitem> 9395 <para> 9396 When on, the parser will emit a warning for any construct that might 9397 have changed meanings since <productname>PostgreSQL</productname> 9.4 as a result 9398 of changes in operator precedence. This is useful for auditing 9399 applications to see if precedence changes have broken anything; but it 9400 is not meant to be kept turned on in production, since it will warn 9401 about some perfectly valid, standard-compliant SQL code. 9402 The default is <literal>off</literal>. 9403 </para> 9404 9405 <para> 9406 See <xref linkend="sql-precedence"/> for more information. 9407 </para> 9408 </listitem> 9409 </varlistentry> 9410 9411 <varlistentry id="guc-quote-all-identifiers" xreflabel="quote-all-identifiers"> 9412 <term><varname>quote_all_identifiers</varname> (<type>boolean</type>) 9413 <indexterm> 9414 <primary><varname>quote_all_identifiers</varname> configuration parameter</primary> 9415 </indexterm> 9416 </term> 9417 <listitem> 9418 <para> 9419 When the database generates SQL, force all identifiers to be quoted, 9420 even if they are not (currently) keywords. This will affect the 9421 output of <command>EXPLAIN</command> as well as the results of functions 9422 like <function>pg_get_viewdef</function>. See also the 9423 <option>--quote-all-identifiers</option> option of 9424 <xref linkend="app-pgdump"/> and <xref linkend="app-pg-dumpall"/>. 9425 </para> 9426 </listitem> 9427 </varlistentry> 9428 9429 <varlistentry id="guc-standard-conforming-strings" xreflabel="standard_conforming_strings"> 9430 <term><varname>standard_conforming_strings</varname> (<type>boolean</type>) 9431 <indexterm><primary>strings</primary><secondary>standard conforming</secondary></indexterm> 9432 <indexterm> 9433 <primary><varname>standard_conforming_strings</varname> configuration parameter</primary> 9434 </indexterm> 9435 </term> 9436 <listitem> 9437 <para> 9438 This controls whether ordinary string literals 9439 (<literal>'...'</literal>) treat backslashes literally, as specified in 9440 the SQL standard. 9441 Beginning in <productname>PostgreSQL</productname> 9.1, the default is 9442 <literal>on</literal> (prior releases defaulted to <literal>off</literal>). 9443 Applications can check this 9444 parameter to determine how string literals will be processed. 9445 The presence of this parameter can also be taken as an indication 9446 that the escape string syntax (<literal>E'...'</literal>) is supported. 9447 Escape string syntax (<xref linkend="sql-syntax-strings-escape"/>) 9448 should be used if an application desires 9449 backslashes to be treated as escape characters. 9450 </para> 9451 </listitem> 9452 </varlistentry> 9453 9454 <varlistentry id="guc-synchronize-seqscans" xreflabel="synchronize_seqscans"> 9455 <term><varname>synchronize_seqscans</varname> (<type>boolean</type>) 9456 <indexterm> 9457 <primary><varname>synchronize_seqscans</varname> configuration parameter</primary> 9458 </indexterm> 9459 </term> 9460 <listitem> 9461 <para> 9462 This allows sequential scans of large tables to synchronize with each 9463 other, so that concurrent scans read the same block at about the 9464 same time and hence share the I/O workload. When this is enabled, 9465 a scan might start in the middle of the table and then <quote>wrap 9466 around</quote> the end to cover all rows, so as to synchronize with the 9467 activity of scans already in progress. This can result in 9468 unpredictable changes in the row ordering returned by queries that 9469 have no <literal>ORDER BY</literal> clause. Setting this parameter to 9470 <literal>off</literal> ensures the pre-8.3 behavior in which a sequential 9471 scan always starts from the beginning of the table. The default 9472 is <literal>on</literal>. 9473 </para> 9474 </listitem> 9475 </varlistentry> 9476 9477 </variablelist> 9478 </sect2> 9479 9480 <sect2 id="runtime-config-compatible-clients"> 9481 <title>Platform and Client Compatibility</title> 9482 <variablelist> 9483 9484 <varlistentry id="guc-transform-null-equals" xreflabel="transform_null_equals"> 9485 <term><varname>transform_null_equals</varname> (<type>boolean</type>) 9486 <indexterm><primary>IS NULL</primary></indexterm> 9487 <indexterm> 9488 <primary><varname>transform_null_equals</varname> configuration parameter</primary> 9489 </indexterm> 9490 </term> 9491 <listitem> 9492 <para> 9493 When on, expressions of the form <literal><replaceable>expr</replaceable> = 9494 NULL</literal> (or <literal>NULL = 9495 <replaceable>expr</replaceable></literal>) are treated as 9496 <literal><replaceable>expr</replaceable> IS NULL</literal>, that is, they 9497 return true if <replaceable>expr</replaceable> evaluates to the null value, 9498 and false otherwise. The correct SQL-spec-compliant behavior of 9499 <literal><replaceable>expr</replaceable> = NULL</literal> is to always 9500 return null (unknown). Therefore this parameter defaults to 9501 <literal>off</literal>. 9502 </para> 9503 9504 <para> 9505 However, filtered forms in <productname>Microsoft 9506 Access</productname> generate queries that appear to use 9507 <literal><replaceable>expr</replaceable> = NULL</literal> to test for 9508 null values, so if you use that interface to access the database you 9509 might want to turn this option on. Since expressions of the 9510 form <literal><replaceable>expr</replaceable> = NULL</literal> always 9511 return the null value (using the SQL standard interpretation), they are not 9512 very useful and do not appear often in normal applications so 9513 this option does little harm in practice. But new users are 9514 frequently confused about the semantics of expressions 9515 involving null values, so this option is off by default. 9516 </para> 9517 9518 <para> 9519 Note that this option only affects the exact form <literal>= NULL</literal>, 9520 not other comparison operators or other expressions 9521 that are computationally equivalent to some expression 9522 involving the equals operator (such as <literal>IN</literal>). 9523 Thus, this option is not a general fix for bad programming. 9524 </para> 9525 9526 <para> 9527 Refer to <xref linkend="functions-comparison"/> for related information. 9528 </para> 9529 </listitem> 9530 </varlistentry> 9531 9532 </variablelist> 9533 </sect2> 9534 </sect1> 9535 9536 <sect1 id="runtime-config-error-handling"> 9537 <title>Error Handling</title> 9538 9539 <variablelist> 9540 9541 <varlistentry id="guc-exit-on-error" xreflabel="exit_on_error"> 9542 <term><varname>exit_on_error</varname> (<type>boolean</type>) 9543 <indexterm> 9544 <primary><varname>exit_on_error</varname> configuration parameter</primary> 9545 </indexterm> 9546 </term> 9547 <listitem> 9548 <para> 9549 If on, any error will terminate the current session. By default, 9550 this is set to off, so that only FATAL errors will terminate the 9551 session. 9552 </para> 9553 </listitem> 9554 </varlistentry> 9555 9556 <varlistentry id="guc-restart-after-crash" xreflabel="restart_after_crash"> 9557 <term><varname>restart_after_crash</varname> (<type>boolean</type>) 9558 <indexterm> 9559 <primary><varname>restart_after_crash</varname> configuration parameter</primary> 9560 </indexterm> 9561 </term> 9562 <listitem> 9563 <para> 9564 When set to on, which is the default, <productname>PostgreSQL</productname> 9565 will automatically reinitialize after a backend crash. Leaving this 9566 value set to on is normally the best way to maximize the availability 9567 of the database. However, in some circumstances, such as when 9568 <productname>PostgreSQL</productname> is being invoked by clusterware, it may be 9569 useful to disable the restart so that the clusterware can gain 9570 control and take any actions it deems appropriate. 9571 </para> 9572 9573 <para> 9574 This parameter can only be set in the <filename>postgresql.conf</filename> 9575 file or on the server command line. 9576 </para> 9577 </listitem> 9578 </varlistentry> 9579 9580 <varlistentry id="guc-data-sync-retry" xreflabel="data_sync_retry"> 9581 <term><varname>data_sync_retry</varname> (<type>boolean</type>) 9582 <indexterm> 9583 <primary><varname>data_sync_retry</varname> configuration parameter</primary> 9584 </indexterm> 9585 </term> 9586 <listitem> 9587 <para> 9588 When set to off, which is the default, <productname>PostgreSQL</productname> 9589 will raise a PANIC-level error on failure to flush modified data files 9590 to the file system. This causes the database server to crash. This 9591 parameter can only be set at server start. 9592 </para> 9593 <para> 9594 On some operating systems, the status of data in the kernel's page 9595 cache is unknown after a write-back failure. In some cases it might 9596 have been entirely forgotten, making it unsafe to retry; the second 9597 attempt may be reported as successful, when in fact the data has been 9598 lost. In these circumstances, the only way to avoid data loss is to 9599 recover from the WAL after any failure is reported, preferably 9600 after investigating the root cause of the failure and replacing any 9601 faulty hardware. 9602 </para> 9603 <para> 9604 If set to on, <productname>PostgreSQL</productname> will instead 9605 report an error but continue to run so that the data flushing 9606 operation can be retried in a later checkpoint. Only set it to on 9607 after investigating the operating system's treatment of buffered data 9608 in case of write-back failure. 9609 </para> 9610 </listitem> 9611 </varlistentry> 9612 9613 </variablelist> 9614 9615 </sect1> 9616 9617 <sect1 id="runtime-config-preset"> 9618 <title>Preset Options</title> 9619 9620 <para> 9621 The following <quote>parameters</quote> are read-only, and are determined 9622 when <productname>PostgreSQL</productname> is compiled or when it is 9623 installed. As such, they have been excluded from the sample 9624 <filename>postgresql.conf</filename> file. These options report 9625 various aspects of <productname>PostgreSQL</productname> behavior 9626 that might be of interest to certain applications, particularly 9627 administrative front-ends. 9628 </para> 9629 9630 <variablelist> 9631 9632 <varlistentry id="guc-block-size" xreflabel="block_size"> 9633 <term><varname>block_size</varname> (<type>integer</type>) 9634 <indexterm> 9635 <primary><varname>block_size</varname> configuration parameter</primary> 9636 </indexterm> 9637 </term> 9638 <listitem> 9639 <para> 9640 Reports the size of a disk block. It is determined by the value 9641 of <literal>BLCKSZ</literal> when building the server. The default 9642 value is 8192 bytes. The meaning of some configuration 9643 variables (such as <xref linkend="guc-shared-buffers"/>) is 9644 influenced by <varname>block_size</varname>. See <xref 9645 linkend="runtime-config-resource"/> for information. 9646 </para> 9647 </listitem> 9648 </varlistentry> 9649 9650 <varlistentry id="guc-data-checksums" xreflabel="data_checksums"> 9651 <term><varname>data_checksums</varname> (<type>boolean</type>) 9652 <indexterm> 9653 <primary><varname>data_checksums</varname> configuration parameter</primary> 9654 </indexterm> 9655 </term> 9656 <listitem> 9657 <para> 9658 Reports whether data checksums are enabled for this cluster. 9659 See <xref linkend="app-initdb-data-checksums"/> for more information. 9660 </para> 9661 </listitem> 9662 </varlistentry> 9663 9664 <varlistentry id="guc-data-directory-mode" xreflabel="data_directory_mode"> 9665 <term><varname>data_directory_mode</varname> (<type>integer</type>) 9666 <indexterm> 9667 <primary><varname>data_directory_mode</varname> configuration parameter</primary> 9668 </indexterm> 9669 </term> 9670 <listitem> 9671 <para> 9672 On Unix systems this parameter reports the permissions of the data 9673 directory defined by (<xref linkend="guc-data-directory"/>) at startup. 9674 (On Microsoft Windows this parameter will always display 9675 <literal>0700</literal>). See 9676 <xref linkend="app-initdb-allow-group-access"/> for more information. 9677 </para> 9678 </listitem> 9679 </varlistentry> 9680 9681 <varlistentry id="guc-debug-assertions" xreflabel="debug_assertions"> 9682 <term><varname>debug_assertions</varname> (<type>boolean</type>) 9683 <indexterm> 9684 <primary><varname>debug_assertions</varname> configuration parameter</primary> 9685 </indexterm> 9686 </term> 9687 <listitem> 9688 <para> 9689 Reports whether <productname>PostgreSQL</productname> has been built 9690 with assertions enabled. That is the case if the 9691 macro <symbol>USE_ASSERT_CHECKING</symbol> is defined 9692 when <productname>PostgreSQL</productname> is built (accomplished 9693 e.g., by the <command>configure</command> option 9694 <option>--enable-cassert</option>). By 9695 default <productname>PostgreSQL</productname> is built without 9696 assertions. 9697 </para> 9698 </listitem> 9699 </varlistentry> 9700 9701 <varlistentry id="guc-integer-datetimes" xreflabel="integer_datetimes"> 9702 <term><varname>integer_datetimes</varname> (<type>boolean</type>) 9703 <indexterm> 9704 <primary><varname>integer_datetimes</varname> configuration parameter</primary> 9705 </indexterm> 9706 </term> 9707 <listitem> 9708 <para> 9709 Reports whether <productname>PostgreSQL</productname> was built with support for 9710 64-bit-integer dates and times. As of <productname>PostgreSQL</productname> 10, 9711 this is always <literal>on</literal>. 9712 </para> 9713 </listitem> 9714 </varlistentry> 9715 9716 <varlistentry id="guc-lc-collate" xreflabel="lc_collate"> 9717 <term><varname>lc_collate</varname> (<type>string</type>) 9718 <indexterm> 9719 <primary><varname>lc_collate</varname> configuration parameter</primary> 9720 </indexterm> 9721 </term> 9722 <listitem> 9723 <para> 9724 Reports the locale in which sorting of textual data is done. 9725 See <xref linkend="locale"/> for more information. 9726 This value is determined when a database is created. 9727 </para> 9728 </listitem> 9729 </varlistentry> 9730 9731 <varlistentry id="guc-lc-ctype" xreflabel="lc_ctype"> 9732 <term><varname>lc_ctype</varname> (<type>string</type>) 9733 <indexterm> 9734 <primary><varname>lc_ctype</varname> configuration parameter</primary> 9735 </indexterm> 9736 </term> 9737 <listitem> 9738 <para> 9739 Reports the locale that determines character classifications. 9740 See <xref linkend="locale"/> for more information. 9741 This value is determined when a database is created. 9742 Ordinarily this will be the same as <varname>lc_collate</varname>, 9743 but for special applications it might be set differently. 9744 </para> 9745 </listitem> 9746 </varlistentry> 9747 9748 <varlistentry id="guc-max-function-args" xreflabel="max_function_args"> 9749 <term><varname>max_function_args</varname> (<type>integer</type>) 9750 <indexterm> 9751 <primary><varname>max_function_args</varname> configuration parameter</primary> 9752 </indexterm> 9753 </term> 9754 <listitem> 9755 <para> 9756 Reports the maximum number of function arguments. It is determined by 9757 the value of <literal>FUNC_MAX_ARGS</literal> when building the server. The 9758 default value is 100 arguments. 9759 </para> 9760 </listitem> 9761 </varlistentry> 9762 9763 <varlistentry id="guc-max-identifier-length" xreflabel="max_identifier_length"> 9764 <term><varname>max_identifier_length</varname> (<type>integer</type>) 9765 <indexterm> 9766 <primary><varname>max_identifier_length</varname> configuration parameter</primary> 9767 </indexterm> 9768 </term> 9769 <listitem> 9770 <para> 9771 Reports the maximum identifier length. It is determined as one 9772 less than the value of <literal>NAMEDATALEN</literal> when building 9773 the server. The default value of <literal>NAMEDATALEN</literal> is 9774 64; therefore the default 9775 <varname>max_identifier_length</varname> is 63 bytes, which 9776 can be less than 63 characters when using multibyte encodings. 9777 </para> 9778 </listitem> 9779 </varlistentry> 9780 9781 <varlistentry id="guc-max-index-keys" xreflabel="max_index_keys"> 9782 <term><varname>max_index_keys</varname> (<type>integer</type>) 9783 <indexterm> 9784 <primary><varname>max_index_keys</varname> configuration parameter</primary> 9785 </indexterm> 9786 </term> 9787 <listitem> 9788 <para> 9789 Reports the maximum number of index keys. It is determined by 9790 the value of <literal>INDEX_MAX_KEYS</literal> when building the server. The 9791 default value is 32 keys. 9792 </para> 9793 </listitem> 9794 </varlistentry> 9795 9796 <varlistentry id="guc-segment-size" xreflabel="segment_size"> 9797 <term><varname>segment_size</varname> (<type>integer</type>) 9798 <indexterm> 9799 <primary><varname>segment_size</varname> configuration parameter</primary> 9800 </indexterm> 9801 </term> 9802 <listitem> 9803 <para> 9804 Reports the number of blocks (pages) that can be stored within a file 9805 segment. It is determined by the value of <literal>RELSEG_SIZE</literal> 9806 when building the server. The maximum size of a segment file in bytes 9807 is equal to <varname>segment_size</varname> multiplied by 9808 <varname>block_size</varname>; by default this is 1GB. 9809 </para> 9810 </listitem> 9811 </varlistentry> 9812 9813 <varlistentry id="guc-server-encoding" xreflabel="server_encoding"> 9814 <term><varname>server_encoding</varname> (<type>string</type>) 9815 <indexterm> 9816 <primary><varname>server_encoding</varname> configuration parameter</primary> 9817 </indexterm> 9818 <indexterm><primary>character set</primary></indexterm> 9819 </term> 9820 <listitem> 9821 <para> 9822 Reports the database encoding (character set). 9823 It is determined when the database is created. Ordinarily, 9824 clients need only be concerned with the value of <xref 9825 linkend="guc-client-encoding"/>. 9826 </para> 9827 </listitem> 9828 </varlistentry> 9829 9830 <varlistentry id="guc-server-version" xreflabel="server_version"> 9831 <term><varname>server_version</varname> (<type>string</type>) 9832 <indexterm> 9833 <primary><varname>server_version</varname> configuration parameter</primary> 9834 </indexterm> 9835 </term> 9836 <listitem> 9837 <para> 9838 Reports the version number of the server. It is determined by the 9839 value of <literal>PG_VERSION</literal> when building the server. 9840 </para> 9841 </listitem> 9842 </varlistentry> 9843 9844 <varlistentry id="guc-server-version-num" xreflabel="server_version_num"> 9845 <term><varname>server_version_num</varname> (<type>integer</type>) 9846 <indexterm> 9847 <primary><varname>server_version_num</varname> configuration parameter</primary> 9848 </indexterm> 9849 </term> 9850 <listitem> 9851 <para> 9852 Reports the version number of the server as an integer. It is determined 9853 by the value of <literal>PG_VERSION_NUM</literal> when building the server. 9854 </para> 9855 </listitem> 9856 </varlistentry> 9857 9858 <varlistentry id="guc-ssl-library" xreflabel="ssl_library"> 9859 <term><varname>ssl_library</varname> (<type>string</type>) 9860 <indexterm> 9861 <primary><varname>ssl_library</varname> configuration parameter</primary> 9862 </indexterm> 9863 </term> 9864 <listitem> 9865 <para> 9866 Reports the name of the SSL library that this 9867 <productname>PostgreSQL</productname> server was built with (even if 9868 SSL is not currently configured or in use on this instance), for 9869 example <literal>OpenSSL</literal>, or an empty string if none. 9870 </para> 9871 </listitem> 9872 </varlistentry> 9873 9874 <varlistentry id="guc-wal-block-size" xreflabel="wal_block_size"> 9875 <term><varname>wal_block_size</varname> (<type>integer</type>) 9876 <indexterm> 9877 <primary><varname>wal_block_size</varname> configuration parameter</primary> 9878 </indexterm> 9879 </term> 9880 <listitem> 9881 <para> 9882 Reports the size of a WAL disk block. It is determined by the value 9883 of <literal>XLOG_BLCKSZ</literal> when building the server. The default value 9884 is 8192 bytes. 9885 </para> 9886 </listitem> 9887 </varlistentry> 9888 9889 <varlistentry id="guc-wal-segment-size" xreflabel="wal_segment_size"> 9890 <term><varname>wal_segment_size</varname> (<type>integer</type>) 9891 <indexterm> 9892 <primary><varname>wal_segment_size</varname> configuration parameter</primary> 9893 </indexterm> 9894 </term> 9895 <listitem> 9896 <para> 9897 Reports the size of write ahead log segments. The default value is 9898 16MB. See <xref linkend="wal-configuration"/> for more information. 9899 </para> 9900 </listitem> 9901 </varlistentry> 9902 9903 </variablelist> 9904 </sect1> 9905 9906 <sect1 id="runtime-config-custom"> 9907 <title>Customized Options</title> 9908 9909 <para> 9910 This feature was designed to allow parameters not normally known to 9911 <productname>PostgreSQL</productname> to be added by add-on modules 9912 (such as procedural languages). This allows extension modules to be 9913 configured in the standard ways. 9914 </para> 9915 9916 <para> 9917 Custom options have two-part names: an extension name, then a dot, then 9918 the parameter name proper, much like qualified names in SQL. An example 9919 is <literal>plpgsql.variable_conflict</literal>. 9920 </para> 9921 9922 <para> 9923 Because custom options may need to be set in processes that have not 9924 loaded the relevant extension module, <productname>PostgreSQL</productname> 9925 will accept a setting for any two-part parameter name. Such variables 9926 are treated as placeholders and have no function until the module that 9927 defines them is loaded. When an extension module is loaded, it will add 9928 its variable definitions, convert any placeholder values according to 9929 those definitions, and issue warnings for any unrecognized placeholders 9930 that begin with its extension name. 9931 </para> 9932 </sect1> 9933 9934 <sect1 id="runtime-config-developer"> 9935 <title>Developer Options</title> 9936 9937 <para> 9938 The following parameters are intended for work on the 9939 <productname>PostgreSQL</productname> source code, and in some cases 9940 to assist with recovery of severely damaged databases. There 9941 should be no reason to use them on a production database. 9942 As such, they have been excluded from the sample 9943 <filename>postgresql.conf</filename> file. Note that many of these 9944 parameters require special source compilation flags to work at all. 9945 </para> 9946 9947 <variablelist> 9948 <varlistentry id="guc-allow-system-table-mods" xreflabel="allow_system_table_mods"> 9949 <term><varname>allow_system_table_mods</varname> (<type>boolean</type>) 9950 <indexterm> 9951 <primary><varname>allow_system_table_mods</varname> configuration parameter</primary> 9952 </indexterm> 9953 </term> 9954 <listitem> 9955 <para> 9956 Allows modification of the structure of system tables as well as 9957 certain other risky actions on system tables. This is otherwise not 9958 allowed even for superusers. Ill-advised use of this setting can 9959 cause irretrievable data loss or seriously corrupt the database 9960 system. Only superusers can change this setting. 9961 </para> 9962 </listitem> 9963 </varlistentry> 9964 9965 <varlistentry id="guc-backtrace-functions" xreflabel="backtrace_functions"> 9966 <term><varname>backtrace_functions</varname> (<type>string</type>) 9967 <indexterm> 9968 <primary><varname>backtrace_functions</varname> configuration parameter</primary> 9969 </indexterm> 9970 </term> 9971 <listitem> 9972 <para> 9973 This parameter contains a comma-separated list of C function names. 9974 If an error is raised and the name of the internal C function where 9975 the error happens matches a value in the list, then a backtrace is 9976 written to the server log together with the error message. This can 9977 be used to debug specific areas of the source code. 9978 </para> 9979 9980 <para> 9981 Backtrace support is not available on all platforms, and the quality 9982 of the backtraces depends on compilation options. 9983 </para> 9984 9985 <para> 9986 This parameter can only be set by superusers. 9987 </para> 9988 </listitem> 9989 </varlistentry> 9990 9991 <varlistentry id="guc-ignore-system-indexes" xreflabel="ignore_system_indexes"> 9992 <term><varname>ignore_system_indexes</varname> (<type>boolean</type>) 9993 <indexterm> 9994 <primary><varname>ignore_system_indexes</varname> configuration parameter</primary> 9995 </indexterm> 9996 </term> 9997 <listitem> 9998 <para> 9999 Ignore system indexes when reading system tables (but still 10000 update the indexes when modifying the tables). This is useful 10001 when recovering from damaged system indexes. 10002 This parameter cannot be changed after session start. 10003 </para> 10004 </listitem> 10005 </varlistentry> 10006 10007 <varlistentry id="guc-post-auth-delay" xreflabel="post_auth_delay"> 10008 <term><varname>post_auth_delay</varname> (<type>integer</type>) 10009 <indexterm> 10010 <primary><varname>post_auth_delay</varname> configuration parameter</primary> 10011 </indexterm> 10012 </term> 10013 <listitem> 10014 <para> 10015 The amount of time to delay when a new 10016 server process is started, after it conducts the 10017 authentication procedure. This is intended to give developers an 10018 opportunity to attach to the server process with a debugger. 10019 If this value is specified without units, it is taken as seconds. 10020 A value of zero (the default) disables the delay. 10021 This parameter cannot be changed after session start. 10022 </para> 10023 </listitem> 10024 </varlistentry> 10025 10026 <varlistentry id="guc-pre-auth-delay" xreflabel="pre_auth_delay"> 10027 <term><varname>pre_auth_delay</varname> (<type>integer</type>) 10028 <indexterm> 10029 <primary><varname>pre_auth_delay</varname> configuration parameter</primary> 10030 </indexterm> 10031 </term> 10032 <listitem> 10033 <para> 10034 The amount of time to delay just after a 10035 new server process is forked, before it conducts the 10036 authentication procedure. This is intended to give developers an 10037 opportunity to attach to the server process with a debugger to 10038 trace down misbehavior in authentication. 10039 If this value is specified without units, it is taken as seconds. 10040 A value of zero (the default) disables the delay. 10041 This parameter can only be set in the <filename>postgresql.conf</filename> 10042 file or on the server command line. 10043 </para> 10044 </listitem> 10045 </varlistentry> 10046 10047 <varlistentry id="guc-trace-notify" xreflabel="trace_notify"> 10048 <term><varname>trace_notify</varname> (<type>boolean</type>) 10049 <indexterm> 10050 <primary><varname>trace_notify</varname> configuration parameter</primary> 10051 </indexterm> 10052 </term> 10053 <listitem> 10054 <para> 10055 Generates a great amount of debugging output for the 10056 <command>LISTEN</command> and <command>NOTIFY</command> 10057 commands. <xref linkend="guc-client-min-messages"/> or 10058 <xref linkend="guc-log-min-messages"/> must be 10059 <literal>DEBUG1</literal> or lower to send this output to the 10060 client or server logs, respectively. 10061 </para> 10062 </listitem> 10063 </varlistentry> 10064 10065 <varlistentry id="guc-trace-recovery-messages" xreflabel="trace_recovery_messages"> 10066 <term><varname>trace_recovery_messages</varname> (<type>enum</type>) 10067 <indexterm> 10068 <primary><varname>trace_recovery_messages</varname> configuration parameter</primary> 10069 </indexterm> 10070 </term> 10071 <listitem> 10072 <para> 10073 Enables logging of recovery-related debugging output that otherwise 10074 would not be logged. This parameter allows the user to override the 10075 normal setting of <xref linkend="guc-log-min-messages"/>, but only for 10076 specific messages. This is intended for use in debugging Hot Standby. 10077 Valid values are <literal>DEBUG5</literal>, <literal>DEBUG4</literal>, 10078 <literal>DEBUG3</literal>, <literal>DEBUG2</literal>, <literal>DEBUG1</literal>, and 10079 <literal>LOG</literal>. The default, <literal>LOG</literal>, does not affect 10080 logging decisions at all. The other values cause recovery-related 10081 debug messages of that priority or higher to be logged as though they 10082 had <literal>LOG</literal> priority; for common settings of 10083 <varname>log_min_messages</varname> this results in unconditionally sending 10084 them to the server log. 10085 This parameter can only be set in the <filename>postgresql.conf</filename> 10086 file or on the server command line. 10087 </para> 10088 </listitem> 10089 </varlistentry> 10090 10091 <varlistentry id="guc-trace-sort" xreflabel="trace_sort"> 10092 <term><varname>trace_sort</varname> (<type>boolean</type>) 10093 <indexterm> 10094 <primary><varname>trace_sort</varname> configuration parameter</primary> 10095 </indexterm> 10096 </term> 10097 <listitem> 10098 <para> 10099 If on, emit information about resource usage during sort operations. 10100 This parameter is only available if the <symbol>TRACE_SORT</symbol> macro 10101 was defined when <productname>PostgreSQL</productname> was compiled. 10102 (However, <symbol>TRACE_SORT</symbol> is currently defined by default.) 10103 </para> 10104 </listitem> 10105 </varlistentry> 10106 10107 <varlistentry> 10108 <term><varname>trace_locks</varname> (<type>boolean</type>) 10109 <indexterm> 10110 <primary><varname>trace_locks</varname> configuration parameter</primary> 10111 </indexterm> 10112 </term> 10113 <listitem> 10114 <para> 10115 If on, emit information about lock usage. Information dumped 10116 includes the type of lock operation, the type of lock and the unique 10117 identifier of the object being locked or unlocked. Also included 10118 are bit masks for the lock types already granted on this object as 10119 well as for the lock types awaited on this object. For each lock 10120 type a count of the number of granted locks and waiting locks is 10121 also dumped as well as the totals. An example of the log file output 10122 is shown here: 10123<screen> 10124LOG: LockAcquire: new: lock(0xb7acd844) id(24688,24696,0,0,0,1) 10125 grantMask(0) req(0,0,0,0,0,0,0)=0 grant(0,0,0,0,0,0,0)=0 10126 wait(0) type(AccessShareLock) 10127LOG: GrantLock: lock(0xb7acd844) id(24688,24696,0,0,0,1) 10128 grantMask(2) req(1,0,0,0,0,0,0)=1 grant(1,0,0,0,0,0,0)=1 10129 wait(0) type(AccessShareLock) 10130LOG: UnGrantLock: updated: lock(0xb7acd844) id(24688,24696,0,0,0,1) 10131 grantMask(0) req(0,0,0,0,0,0,0)=0 grant(0,0,0,0,0,0,0)=0 10132 wait(0) type(AccessShareLock) 10133LOG: CleanUpLock: deleting: lock(0xb7acd844) id(24688,24696,0,0,0,1) 10134 grantMask(0) req(0,0,0,0,0,0,0)=0 grant(0,0,0,0,0,0,0)=0 10135 wait(0) type(INVALID) 10136</screen> 10137 Details of the structure being dumped may be found in 10138 <filename>src/include/storage/lock.h</filename>. 10139 </para> 10140 <para> 10141 This parameter is only available if the <symbol>LOCK_DEBUG</symbol> 10142 macro was defined when <productname>PostgreSQL</productname> was 10143 compiled. 10144 </para> 10145 </listitem> 10146 </varlistentry> 10147 10148 <varlistentry> 10149 <term><varname>trace_lwlocks</varname> (<type>boolean</type>) 10150 <indexterm> 10151 <primary><varname>trace_lwlocks</varname> configuration parameter</primary> 10152 </indexterm> 10153 </term> 10154 <listitem> 10155 <para> 10156 If on, emit information about lightweight lock usage. Lightweight 10157 locks are intended primarily to provide mutual exclusion of access 10158 to shared-memory data structures. 10159 </para> 10160 <para> 10161 This parameter is only available if the <symbol>LOCK_DEBUG</symbol> 10162 macro was defined when <productname>PostgreSQL</productname> was 10163 compiled. 10164 </para> 10165 </listitem> 10166 </varlistentry> 10167 10168 <varlistentry> 10169 <term><varname>trace_userlocks</varname> (<type>boolean</type>) 10170 <indexterm> 10171 <primary><varname>trace_userlocks</varname> configuration parameter</primary> 10172 </indexterm> 10173 </term> 10174 <listitem> 10175 <para> 10176 If on, emit information about user lock usage. Output is the same 10177 as for <symbol>trace_locks</symbol>, only for advisory locks. 10178 </para> 10179 <para> 10180 This parameter is only available if the <symbol>LOCK_DEBUG</symbol> 10181 macro was defined when <productname>PostgreSQL</productname> was 10182 compiled. 10183 </para> 10184 </listitem> 10185 </varlistentry> 10186 10187 <varlistentry> 10188 <term><varname>trace_lock_oidmin</varname> (<type>integer</type>) 10189 <indexterm> 10190 <primary><varname>trace_lock_oidmin</varname> configuration parameter</primary> 10191 </indexterm> 10192 </term> 10193 <listitem> 10194 <para> 10195 If set, do not trace locks for tables below this OID (used to avoid 10196 output on system tables). 10197 </para> 10198 <para> 10199 This parameter is only available if the <symbol>LOCK_DEBUG</symbol> 10200 macro was defined when <productname>PostgreSQL</productname> was 10201 compiled. 10202 </para> 10203 </listitem> 10204 </varlistentry> 10205 10206 <varlistentry> 10207 <term><varname>trace_lock_table</varname> (<type>integer</type>) 10208 <indexterm> 10209 <primary><varname>trace_lock_table</varname> configuration parameter</primary> 10210 </indexterm> 10211 </term> 10212 <listitem> 10213 <para> 10214 Unconditionally trace locks on this table (OID). 10215 </para> 10216 <para> 10217 This parameter is only available if the <symbol>LOCK_DEBUG</symbol> 10218 macro was defined when <productname>PostgreSQL</productname> was 10219 compiled. 10220 </para> 10221 </listitem> 10222 </varlistentry> 10223 10224 <varlistentry> 10225 <term><varname>debug_deadlocks</varname> (<type>boolean</type>) 10226 <indexterm> 10227 <primary><varname>debug_deadlocks</varname> configuration parameter</primary> 10228 </indexterm> 10229 </term> 10230 <listitem> 10231 <para> 10232 If set, dumps information about all current locks when a 10233 deadlock timeout occurs. 10234 </para> 10235 <para> 10236 This parameter is only available if the <symbol>LOCK_DEBUG</symbol> 10237 macro was defined when <productname>PostgreSQL</productname> was 10238 compiled. 10239 </para> 10240 </listitem> 10241 </varlistentry> 10242 10243 <varlistentry> 10244 <term><varname>log_btree_build_stats</varname> (<type>boolean</type>) 10245 <indexterm> 10246 <primary><varname>log_btree_build_stats</varname> configuration parameter</primary> 10247 </indexterm> 10248 </term> 10249 <listitem> 10250 <para> 10251 If set, logs system resource usage statistics (memory and CPU) on 10252 various B-tree operations. 10253 </para> 10254 <para> 10255 This parameter is only available if the <symbol>BTREE_BUILD_STATS</symbol> 10256 macro was defined when <productname>PostgreSQL</productname> was 10257 compiled. 10258 </para> 10259 </listitem> 10260 </varlistentry> 10261 10262 <varlistentry id="guc-wal-consistency-checking" xreflabel="wal_consistency_checking"> 10263 <term><varname>wal_consistency_checking</varname> (<type>string</type>) 10264 <indexterm> 10265 <primary><varname>wal_consistency_checking</varname> configuration parameter</primary> 10266 </indexterm> 10267 </term> 10268 <listitem> 10269 <para> 10270 This parameter is intended to be used to check for bugs in the WAL 10271 redo routines. When enabled, full-page images of any buffers modified 10272 in conjunction with the WAL record are added to the record. 10273 If the record is subsequently replayed, the system will first apply 10274 each record and then test whether the buffers modified by the record 10275 match the stored images. In certain cases (such as hint bits), minor 10276 variations are acceptable, and will be ignored. Any unexpected 10277 differences will result in a fatal error, terminating recovery. 10278 </para> 10279 10280 <para> 10281 The default value of this setting is the empty string, which disables 10282 the feature. It can be set to <literal>all</literal> to check all 10283 records, or to a comma-separated list of resource managers to check 10284 only records originating from those resource managers. Currently, 10285 the supported resource managers are <literal>heap</literal>, 10286 <literal>heap2</literal>, <literal>btree</literal>, <literal>hash</literal>, 10287 <literal>gin</literal>, <literal>gist</literal>, <literal>sequence</literal>, 10288 <literal>spgist</literal>, <literal>brin</literal>, and <literal>generic</literal>. Only 10289 superusers can change this setting. 10290 </para> 10291 </listitem> 10292 </varlistentry> 10293 10294 <varlistentry id="guc-wal-debug" xreflabel="wal_debug"> 10295 <term><varname>wal_debug</varname> (<type>boolean</type>) 10296 <indexterm> 10297 <primary><varname>wal_debug</varname> configuration parameter</primary> 10298 </indexterm> 10299 </term> 10300 <listitem> 10301 <para> 10302 If on, emit WAL-related debugging output. This parameter is 10303 only available if the <symbol>WAL_DEBUG</symbol> macro was 10304 defined when <productname>PostgreSQL</productname> was 10305 compiled. 10306 </para> 10307 </listitem> 10308 </varlistentry> 10309 10310 <varlistentry id="guc-ignore-checksum-failure" xreflabel="ignore_checksum_failure"> 10311 <term><varname>ignore_checksum_failure</varname> (<type>boolean</type>) 10312 <indexterm> 10313 <primary><varname>ignore_checksum_failure</varname> configuration parameter</primary> 10314 </indexterm> 10315 </term> 10316 <listitem> 10317 <para> 10318 Only has effect if <xref linkend="app-initdb-data-checksums"/> are enabled. 10319 </para> 10320 <para> 10321 Detection of a checksum failure during a read normally causes 10322 <productname>PostgreSQL</productname> to report an error, aborting the current 10323 transaction. Setting <varname>ignore_checksum_failure</varname> to on causes 10324 the system to ignore the failure (but still report a warning), and 10325 continue processing. This behavior may <emphasis>cause crashes, propagate 10326 or hide corruption, or other serious problems</emphasis>. However, it may allow 10327 you to get past the error and retrieve undamaged tuples that might still be 10328 present in the table if the block header is still sane. If the header is 10329 corrupt an error will be reported even if this option is enabled. The 10330 default setting is <literal>off</literal>, and it can only be changed by a superuser. 10331 </para> 10332 </listitem> 10333 </varlistentry> 10334 10335 <varlistentry id="guc-zero-damaged-pages" xreflabel="zero_damaged_pages"> 10336 <term><varname>zero_damaged_pages</varname> (<type>boolean</type>) 10337 <indexterm> 10338 <primary><varname>zero_damaged_pages</varname> configuration parameter</primary> 10339 </indexterm> 10340 </term> 10341 <listitem> 10342 <para> 10343 Detection of a damaged page header normally causes 10344 <productname>PostgreSQL</productname> to report an error, aborting the current 10345 transaction. Setting <varname>zero_damaged_pages</varname> to on causes 10346 the system to instead report a warning, zero out the damaged 10347 page in memory, and continue processing. This behavior <emphasis>will destroy data</emphasis>, 10348 namely all the rows on the damaged page. However, it does allow you to get 10349 past the error and retrieve rows from any undamaged pages that might 10350 be present in the table. It is useful for recovering data if 10351 corruption has occurred due to a hardware or software error. You should 10352 generally not set this on until you have given up hope of recovering 10353 data from the damaged pages of a table. Zeroed-out pages are not 10354 forced to disk so it is recommended to recreate the table or 10355 the index before turning this parameter off again. The 10356 default setting is <literal>off</literal>, and it can only be changed 10357 by a superuser. 10358 </para> 10359 </listitem> 10360 </varlistentry> 10361 10362 <varlistentry id="guc-ignore-invalid-pages" xreflabel="ignore_invalid_pages"> 10363 <term><varname>ignore_invalid_pages</varname> (<type>boolean</type>) 10364 <indexterm> 10365 <primary><varname>ignore_invalid_pages</varname> configuration parameter</primary> 10366 </indexterm> 10367 </term> 10368 <listitem> 10369 <para> 10370 If set to <literal>off</literal> (the default), detection of 10371 WAL records having references to invalid pages during 10372 recovery causes <productname>PostgreSQL</productname> to 10373 raise a PANIC-level error, aborting the recovery. Setting 10374 <varname>ignore_invalid_pages</varname> to <literal>on</literal> 10375 causes the system to ignore invalid page references in WAL records 10376 (but still report a warning), and continue the recovery. 10377 This behavior may <emphasis>cause crashes, data loss, 10378 propagate or hide corruption, or other serious problems</emphasis>. 10379 However, it may allow you to get past the PANIC-level error, 10380 to finish the recovery, and to cause the server to start up. 10381 The parameter can only be set at server start. It only has effect 10382 during recovery or in standby mode. 10383 </para> 10384 </listitem> 10385 </varlistentry> 10386 10387 <varlistentry id="guc-jit-debugging-support" xreflabel="jit_debugging_support"> 10388 <term><varname>jit_debugging_support</varname> (<type>boolean</type>) 10389 <indexterm> 10390 <primary><varname>jit_debugging_support</varname> configuration parameter</primary> 10391 </indexterm> 10392 </term> 10393 <listitem> 10394 <para> 10395 If LLVM has the required functionality, register generated functions 10396 with <productname>GDB</productname>. This makes debugging easier. 10397 The default setting is <literal>off</literal>. 10398 This parameter can only be set at server start. 10399 </para> 10400 </listitem> 10401 </varlistentry> 10402 10403 <varlistentry id="guc-jit-dump-bitcode" xreflabel="jit_dump_bitcode"> 10404 <term><varname>jit_dump_bitcode</varname> (<type>boolean</type>) 10405 <indexterm> 10406 <primary><varname>jit_dump_bitcode</varname> configuration parameter</primary> 10407 </indexterm> 10408 </term> 10409 <listitem> 10410 <para> 10411 Writes the generated <productname>LLVM</productname> IR out to the 10412 file system, inside <xref linkend="guc-data-directory"/>. This is only 10413 useful for working on the internals of the JIT implementation. 10414 The default setting is <literal>off</literal>. 10415 This parameter can only be changed by a superuser. 10416 </para> 10417 </listitem> 10418 </varlistentry> 10419 10420 <varlistentry id="guc-jit-expressions" xreflabel="jit_expressions"> 10421 <term><varname>jit_expressions</varname> (<type>boolean</type>) 10422 <indexterm> 10423 <primary><varname>jit_expressions</varname> configuration parameter</primary> 10424 </indexterm> 10425 </term> 10426 <listitem> 10427 <para> 10428 Determines whether expressions are JIT compiled, when JIT compilation 10429 is activated (see <xref linkend="jit-decision"/>). The default is 10430 <literal>on</literal>. 10431 </para> 10432 </listitem> 10433 </varlistentry> 10434 10435 <varlistentry id="guc-jit-profiling-support" xreflabel="jit_profiling_support"> 10436 <term><varname>jit_profiling_support</varname> (<type>boolean</type>) 10437 <indexterm> 10438 <primary><varname>jit_profiling_support</varname> configuration parameter</primary> 10439 </indexterm> 10440 </term> 10441 <listitem> 10442 <para> 10443 If LLVM has the required functionality, emit the data needed to allow 10444 <productname>perf</productname> to profile functions generated by JIT. 10445 This writes out files to <filename>$HOME/.debug/jit/</filename>; the 10446 user is responsible for performing cleanup when desired. 10447 The default setting is <literal>off</literal>. 10448 This parameter can only be set at server start. 10449 </para> 10450 </listitem> 10451 </varlistentry> 10452 10453 <varlistentry id="guc-jit-tuple-deforming" xreflabel="jit_tuple_deforming"> 10454 <term><varname>jit_tuple_deforming</varname> (<type>boolean</type>) 10455 <indexterm> 10456 <primary><varname>jit_tuple_deforming</varname> configuration parameter</primary> 10457 </indexterm> 10458 </term> 10459 <listitem> 10460 <para> 10461 Determines whether tuple deforming is JIT compiled, when JIT 10462 compilation is activated (see <xref linkend="jit-decision"/>). 10463 The default is <literal>on</literal>. 10464 </para> 10465 </listitem> 10466 </varlistentry> 10467 10468 </variablelist> 10469 </sect1> 10470 <sect1 id="runtime-config-short"> 10471 <title>Short Options</title> 10472 10473 <para> 10474 For convenience there are also single letter command-line option 10475 switches available for some parameters. They are described in 10476 <xref linkend="runtime-config-short-table"/>. Some of these 10477 options exist for historical reasons, and their presence as a 10478 single-letter option does not necessarily indicate an endorsement 10479 to use the option heavily. 10480 </para> 10481 10482 <table id="runtime-config-short-table"> 10483 <title>Short Option Key</title> 10484 <tgroup cols="2"> 10485 <colspec colname="col1" colwidth="1*"/> 10486 <colspec colname="col2" colwidth="2*"/> 10487 <thead> 10488 <row> 10489 <entry>Short Option</entry> 10490 <entry>Equivalent</entry> 10491 </row> 10492 </thead> 10493 10494 <tbody> 10495 <row> 10496 <entry><option>-B <replaceable>x</replaceable></option></entry> 10497 <entry><literal>shared_buffers = <replaceable>x</replaceable></literal></entry> 10498 </row> 10499 <row> 10500 <entry><option>-d <replaceable>x</replaceable></option></entry> 10501 <entry><literal>log_min_messages = DEBUG<replaceable>x</replaceable></literal></entry> 10502 </row> 10503 <row> 10504 <entry><option>-e</option></entry> 10505 <entry><literal>datestyle = euro</literal></entry> 10506 </row> 10507 <row> 10508 <entry> 10509 <option>-fb</option>, <option>-fh</option>, <option>-fi</option>, 10510 <option>-fm</option>, <option>-fn</option>, <option>-fo</option>, 10511 <option>-fs</option>, <option>-ft</option> 10512 </entry> 10513 <entry> 10514 <literal>enable_bitmapscan = off</literal>, 10515 <literal>enable_hashjoin = off</literal>, 10516 <literal>enable_indexscan = off</literal>, 10517 <literal>enable_mergejoin = off</literal>, 10518 <literal>enable_nestloop = off</literal>, 10519 <literal>enable_indexonlyscan = off</literal>, 10520 <literal>enable_seqscan = off</literal>, 10521 <literal>enable_tidscan = off</literal> 10522 </entry> 10523 </row> 10524 <row> 10525 <entry><option>-F</option></entry> 10526 <entry><literal>fsync = off</literal></entry> 10527 </row> 10528 <row> 10529 <entry><option>-h <replaceable>x</replaceable></option></entry> 10530 <entry><literal>listen_addresses = <replaceable>x</replaceable></literal></entry> 10531 </row> 10532 <row> 10533 <entry><option>-i</option></entry> 10534 <entry><literal>listen_addresses = '*'</literal></entry> 10535 </row> 10536 <row> 10537 <entry><option>-k <replaceable>x</replaceable></option></entry> 10538 <entry><literal>unix_socket_directories = <replaceable>x</replaceable></literal></entry> 10539 </row> 10540 <row> 10541 <entry><option>-l</option></entry> 10542 <entry><literal>ssl = on</literal></entry> 10543 </row> 10544 <row> 10545 <entry><option>-N <replaceable>x</replaceable></option></entry> 10546 <entry><literal>max_connections = <replaceable>x</replaceable></literal></entry> 10547 </row> 10548 <row> 10549 <entry><option>-O</option></entry> 10550 <entry><literal>allow_system_table_mods = on</literal></entry> 10551 </row> 10552 <row> 10553 <entry><option>-p <replaceable>x</replaceable></option></entry> 10554 <entry><literal>port = <replaceable>x</replaceable></literal></entry> 10555 </row> 10556 <row> 10557 <entry><option>-P</option></entry> 10558 <entry><literal>ignore_system_indexes = on</literal></entry> 10559 </row> 10560 <row> 10561 <entry><option>-s</option></entry> 10562 <entry><literal>log_statement_stats = on</literal></entry> 10563 </row> 10564 <row> 10565 <entry><option>-S <replaceable>x</replaceable></option></entry> 10566 <entry><literal>work_mem = <replaceable>x</replaceable></literal></entry> 10567 </row> 10568 <row> 10569 <entry><option>-tpa</option>, <option>-tpl</option>, <option>-te</option></entry> 10570 <entry><literal>log_parser_stats = on</literal>, 10571 <literal>log_planner_stats = on</literal>, 10572 <literal>log_executor_stats = on</literal></entry> 10573 </row> 10574 <row> 10575 <entry><option>-W <replaceable>x</replaceable></option></entry> 10576 <entry><literal>post_auth_delay = <replaceable>x</replaceable></literal></entry> 10577 </row> 10578 </tbody> 10579 </tgroup> 10580 </table> 10581 10582 </sect1> 10583</chapter> 10584