set.sgml 26.7 KB
Newer Older
1
<!--
2 3 4 5 6
<<<<<<< set.sgml
$Header: /cvsroot/pgsql/doc/src/sgml/ref/set.sgml,v 1.44 2000/06/09 01:44:00 momjian Exp $
=======
$Header: /cvsroot/pgsql/doc/src/sgml/ref/set.sgml,v 1.44 2000/06/09 01:44:00 momjian Exp $
>>>>>>> 1.43
7 8 9
Postgres documentation
-->

10 11
<refentry id="SQL-SET">
 <refmeta>
12
  <refentrytitle id="SQL-SET-TITLE">
13
   SET
14 15 16 17
  </refentrytitle>
  <refmiscinfo>SQL - Language Statements</refmiscinfo>
 </refmeta>
 <refnamediv>
18
  <refname>
19
   SET
20 21
  </refname>
  <refpurpose>
22
   Set run-time parameters for session
23
  </refpurpose>
24
 </refnamediv>
25 26
 <refsynopsisdiv>
  <refsynopsisdivinfo>
27
   <date>1999-07-20</date>
28 29
  </refsynopsisdivinfo>
  <synopsis>
30
SET <replaceable class="PARAMETER">variable</replaceable> { TO | = } { <replaceable class="PARAMETER">value</replaceable> | '<replaceable class="PARAMETER">value</replaceable>' | DEFAULT }
31
SET CONSTRAINTS {ALL | <replaceable class="parameter">constraintlist</replaceable>} <replaceable>mode</replaceable>
32
SET TIME ZONE { '<replaceable class="PARAMETER">timezone</replaceable>' | LOCAL | DEFAULT }
33
SET TRANSACTION ISOLATION LEVEL { READ COMMITTED | SERIALIZABLE }
34
  </synopsis>
35

36 37 38 39 40
  <refsect2 id="R2-SQL-SET-1">
   <refsect2info>
    <date>1998-09-24</date>
   </refsect2info>
   <title>
41
    Inputs
42 43
   </title>
   <para>
44
		
45 46
    <variablelist>
     <varlistentry>
47
      <term><replaceable class="PARAMETER">variable</replaceable></term>
48
      <listitem>
49 50 51 52 53 54
       <para>
	Settable global parameter.
       </para>
      </listitem>
     </varlistentry>
     <varlistentry>
55
      <term><replaceable class="PARAMETER">value</replaceable></term>
56
      <listitem>
57
       <para>
58
	New value of parameter.  <option>DEFAULT</option> can be
59 60 61
	used to specify resetting the parameter to its default
	value. Lists of strings are allowed, but more complex
	constructs may need to be single or double quoted.
62 63 64 65 66
       </para>
      </listitem>
     </varlistentry>
    </variablelist>
   </para>
67

68 69
   <para>
    The possible variables and allowed values are:
70
		
71 72
    <variablelist>
     <varlistentry>
73
      <term>CLIENT_ENCODING | NAMES</term>
74 75
      <listitem>
       <para>
76
	Sets the multi-byte client encoding. Parameters are:
77
	
78 79
	<variablelist>
	 <varlistentry>
80
	  <term><replaceable class="parameter">value</replaceable></term>
81 82 83 84 85 86 87 88 89 90 91 92
	  <listitem>
	   <para>
	    Sets the multi-byte client encoding to
	    <replaceable class="parameter">value</replaceable>.
	    The specified encoding must be supported by the backend.
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>

       <para>
93 94
	This option is only available if MULTIBYTE support was enabled
	during the configure step of building Postgres.
95 96 97 98 99
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
100
      <term>DATESTYLE</term>
101 102
      <listitem>
       <para>
103 104 105
	Set the date/time representation style. Affects the output format,
	and in some cases it can affect the interpretation of input.

106 107
	<variablelist>
	 <varlistentry>
108
	  <term>ISO</term>
109 110
	  <listitem>
	   <para>
111 112 113 114
	    use ISO 8601-style dates and times
	   </para>
	  </listitem>
	 </varlistentry>
115
	 <varlistentry>
116
	  <term>SQL</term>
117 118
	  <listitem>
	   <para>
119 120 121 122
	    use Oracle/Ingres-style dates and times
	   </para>
	  </listitem>
	 </varlistentry>
123
	 <varlistentry>
124
	  <term>Postgres</term>
125 126
	  <listitem>
	   <para>
127 128 129 130
	    use traditional <productname>Postgres</productname> format
	   </para>
	  </listitem>
	 </varlistentry>
131
	 <varlistentry>
132
	  <term>European</term>
133 134
	  <listitem>
	   <para>
135
	    use <literal>dd/mm/yyyy</literal> for numeric date representations.
136 137 138
	   </para>
	  </listitem>
	 </varlistentry>
139
	 <varlistentry>
140
	  <term>NonEuropean</term>
141 142
	  <listitem>
	   <para>
143
	    use <literal>mm/dd/yyyy</literal> for numeric date representations.
144 145 146
	   </para>
	  </listitem>
	 </varlistentry>
147
	 <varlistentry>
148
	  <term>German</term>
149 150
	  <listitem>
	   <para>
151
	    use <literal>dd.mm.yyyy</literal> for numeric date representations.
152 153 154
	   </para>
	  </listitem>
	 </varlistentry>
155
	 <varlistentry>
156
	  <term>US</term>
157 158
	  <listitem>
	   <para>
159
	    same as <literal>NonEuropean</literal>
160 161 162
	   </para>
	  </listitem>
	 </varlistentry>
163
	 <varlistentry>
164
	  <term>DEFAULT</term>
165 166
	  <listitem>
	   <para>
167
	    restores the default values (<literal>ISO</literal>)
168 169 170 171 172
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>
173 174

       <para>
175
	Date format initialization may be done by:
176 177
	<simplelist>
	 <member>
178
	  Setting the <envar>PGDATESTYLE</envar> environment variable.
179 180 181
	  If PGDATESTYLE is set in the frontend environment of a client
	  based on libpq, libpq will automatically set DATESTYLE to the
	  value of PGDATESTYLE during connection startup.
182 183
	 </member>
	 <member>
184
	  Running postmaster using the option <option>-o -e</option> to set
185
	  dates to the <literal>European</literal> convention.
186
	  Note that this affects only some combinations of date styles; for example
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
	  the ISO style is not affected by this parameter.
	 </member>
	 <member>
	  Changing variables in 
	  <filename>src/backend/utils/init/globals.c</filename>.
	 </member>
	</simplelist>
       </para>
       <para>
	The variables in <filename>globals.c</filename> which can be changed are:
	<simplelist>
	 <member>
	  bool EuroDates = false | true
	 </member>
	 <member>
	  int  DateStyle = USE_ISO_DATES | USE_POSTGRES_DATES | USE_SQL_DATES | USE_GERMAN_DATES
	 </member>
	</simplelist>
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
210
      <term>SEED</term>
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247
      <listitem>
       <para>
	Sets the internal seed for the random number generator.
	
	<variablelist>
	 <varlistentry>
	  <term><replaceable class="parameter">value</replaceable></term>
	  <listitem>
	   <para>
	    The value for the seed to be used by the
	    <function>random</function> catalog function. Significant
	    values are floating point numbers between 0 and 1, which
	    are then multiplied by RAND_MAX. This product will
	    silently overflow if a number outside the range is used.
	   </para>

	   <para>
	    The seed can also be set by invoking the
	    <function>setseed</function> SQL function:

	    <programlisting>
SELECT setseed(<replaceable>value</replaceable>);
	    </programlisting>
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>

       <para>
	This option is only available if MULTIBYTE support was enabled
	during the configure step of building Postgres.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
248
      <term>SERVER_ENCODING</term>
249 250
      <listitem>
       <para>
251
	Sets the multi-byte server encoding to:
252 253 254
	
	<variablelist>
	 <varlistentry>
255
	  <term><replaceable class="parameter">value</replaceable></term>
256 257
	  <listitem>
	   <para>
258
	    The identifying value for the server encoding.
259 260 261 262 263
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>
264

265
       <para>
266 267
	This option is only available if MULTIBYTE support was enabled
	during the configure step of building Postgres.
268
       </para>
269 270 271 272
      </listitem>
     </varlistentry>

     <varlistentry>
273
      <term>CONSTRAINTS</term>
274 275
      <listitem>
       <para>
276 277 278 279 280
	SET CONSTRAINTS affects the behavior of constraint evaluation
	in the current transaction.
	SET CONSTRAINTS, specified
	in SQL3, has these allowed parameters:

281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303
	<variablelist>
	 <varlistentry>
	  <term><replaceable class="parameter">constraintlist</replaceable></term>
	  <listitem>
	   <para>
	    Comma separated list of deferrable constraint names.
	   </para>
	  </listitem>
	 </varlistentry>

	 <varlistentry>
	  <term><replaceable class="parameter">mode</replaceable></term>
	  <listitem>
	   <para>
	    The constraint mode. Allowed values are
	    <option>DEFERRED</option> and <option>IMMEDIATE</option>.
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>

       <para>
B
Bruce Momjian 已提交
304 305
	In <option>IMMEDIATE</option> mode, foreign key constraints
	are checked at the end of each query.
306
       </para>
307 308 309 310 311 312 313 314 315 316

       <para>
	In <option>DEFERRED</option> mode, foreign key constraints
	marked as <option>DEFERRABLE</option> are checked only at
	transaction commit or  until its mode is explicitly set to 
	<option>IMMEDIATE</option>.
	This is actually only done for foreign  key
	constraints,  so  it  does  not  apply  to  UNIQUE  or  other
	constraints.
       </para>
317 318 319 320 321
      </listitem>
     </varlistentry>

     <varlistentry>
      <term>TIME ZONE</term>
322
      <term>TIMEZONE</term>
323 324 325 326 327 328 329 330
      <listitem>
       <para>
	The possible values for timezone depends on your operating
	system. For example on Linux /usr/lib/zoneinfo contains the
	database of timezones.
       </para>
       <para>
	Here are some valid values for timezone:
331
				
332 333
	<variablelist>
	 <varlistentry>
334
	  <term>PST8PDT</term>
335 336 337 338 339 340 341
	  <listitem>
	   <para>
	    set the timezone for California
	   </para>
	  </listitem>
	 </varlistentry>
	 <varlistentry>
342
	  <term>Portugal</term>
343 344 345 346 347 348 349
	  <listitem>
	   <para>
	    set time zone for Portugal.
	   </para>
	  </listitem>
	 </varlistentry>
	 <varlistentry>
350
	  <term>'Europe/Rome'</term>
351 352 353 354 355 356 357
	  <listitem>
	   <para>
	    set time zone for Italy.
	   </para>
	  </listitem>
	 </varlistentry>
	 <varlistentry>
358
	  <term>DEFAULT</term>
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377
	  <listitem>
	   <para>
	    set time zone to your local timezone
	    (value of the TZ environment variable).
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>
       <para>
	If an invalid time zone is specified, the time zone
	becomes GMT (on most systems anyway).
       </para>
       <para>
	The second syntax shown above, allows one to set the timezone
	with a syntax similar to SQL92 <command>SET TIME ZONE</command>.
	The LOCAL keyword is just an alternate form
	of DEFAULT for SQL92 compatibility.
       </para>
378 379 380 381 382
       <para>
        If the PGTZ environment variable is set in the frontend
	environment of a client based on libpq, libpq will automatically
	set TIMEZONE to the value of PGTZ during connection startup.
       </para>
383 384
      </listitem>
     </varlistentry>
385 386

     <varlistentry>
387
      <term>TRANSACTION ISOLATION LEVEL</term>
388 389 390 391 392 393
      <listitem>
       <para>
	Sets the isolation level for the current transaction.
	
	<variablelist>
	 <varlistentry>
394
	  <term>READ COMMITTED</term>
395 396
	  <listitem>
	   <para>
V
Vadim B. Mikheev 已提交
397 398
	    The current transaction queries read only rows committed
	    before a query began. READ COMMITTED is the default.
399
	   </para>
V
Vadim B. Mikheev 已提交
400 401

	   <note>
402
	   <para>
V
Vadim B. Mikheev 已提交
403 404
	    <acronym>SQL92</acronym> standard requires 
	    SERIALIZABLE to be the default isolation level.
405
	   </para>
V
Vadim B. Mikheev 已提交
406
	   </note>
407 408 409 410
	  </listitem>
	 </varlistentry>
	 
	 <varlistentry>
411
	  <term>SERIALIZABLE</term>
412 413
	  <listitem>
	   <para>
V
Vadim B. Mikheev 已提交
414 415 416 417
	    The current transaction queries read only rows committed
	    before first DML statement 
	    (<command>SELECT/INSERT/DELETE/UPDATE/FETCH/COPY_TO</command>)
	    was executed in this transaction. 
418 419 420
	   </para>
	  </listitem>
	 </varlistentry>
V
Vadim B. Mikheev 已提交
421
	 
422 423 424 425
	</variablelist>
       </para>
      </listitem>
     </varlistentry>
426 427
    </variablelist>
   </para>
428

429 430 431 432 433 434
   <para>
    There are also several internal or optimization
    parameters which can be specified
    by the <command>SET</command> command:
    
    <variablelist>
435
     <varlistentry>
B
Bruce Momjian 已提交
436
      <term>PG_OPTIONS</term>
437 438 439 440 441 442 443
      <listitem>
       <para>
        Sets various backend parameters.
       </para>
      </listitem>
     </varlistentry>
    
444
     <varlistentry>
445
      <term>RANDOM_PAGE_COST</term>
446 447
      <listitem>
       <para>
448 449 450
        Sets the optimizer's estimate of the cost of a nonsequentially
	fetched disk page.  This is measured as a multiple of the cost
	of a sequential page fetch.
451 452 453
	
	<variablelist>
	 <varlistentry>
454
	  <term><replaceable class="parameter">float8</replaceable></term>
455 456
	  <listitem>
	   <para>
457 458
	    Set the cost of a random page access
	    to the specified floating-point value.
459 460 461
	   </para>
	  </listitem>
	 </varlistentry>
462 463 464 465 466 467 468 469 470 471 472 473 474 475
	</variablelist>
       </para>
      </listitem>
     </varlistentry>
    
     <varlistentry>
      <term>CPU_TUPLE_COST</term>
      <listitem>
       <para>
        Sets the optimizer's estimate of the cost of processing each
	tuple during a query.  This is measured as a fraction of the cost
	of a sequential page fetch.
	
	<variablelist>
476
	 <varlistentry>
477
	  <term><replaceable class="parameter">float8</replaceable></term>
478 479
	  <listitem>
	   <para>
480 481
	    Set the cost of per-tuple CPU processing
	    to the specified floating-point value.
482 483 484 485 486
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>
487 488 489 490 491 492
      </listitem>
     </varlistentry>
    
     <varlistentry>
      <term>CPU_INDEX_TUPLE_COST</term>
      <listitem>
493
       <para>
494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555
        Sets the optimizer's estimate of the cost of processing each
	index tuple during an index scan.  This is measured as a fraction
	of the cost of a sequential page fetch.
	
	<variablelist>
	 <varlistentry>
	  <term><replaceable class="parameter">float8</replaceable></term>
	  <listitem>
	   <para>
	    Set the cost of per-index-tuple CPU processing
	    to the specified floating-point value.
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>
      </listitem>
     </varlistentry>
    
     <varlistentry>
      <term>CPU_OPERATOR_COST</term>
      <listitem>
       <para>
        Sets the optimizer's estimate of the cost of processing each
	operator in a WHERE clause.  This is measured as a fraction
	of the cost of a sequential page fetch.
	
	<variablelist>
	 <varlistentry>
	  <term><replaceable class="parameter">float8</replaceable></term>
	  <listitem>
	   <para>
	    Set the cost of per-operator CPU processing
	    to the specified floating-point value.
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>
      </listitem>
     </varlistentry>
    
     <varlistentry>
      <term>EFFECTIVE_CACHE_SIZE</term>
      <listitem>
       <para>
        Sets the optimizer's assumption about the effective size of the
	disk cache (that is, the portion of the kernel's disk cache that
	will be used for Postgres data files).  This is measured in disk
	pages, which are normally 8Kb apiece.
	
	<variablelist>
	 <varlistentry>
	  <term><replaceable class="parameter">float8</replaceable></term>
	  <listitem>
	   <para>
	    Set the assumed cache size
	    to the specified floating-point value.
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
556 557 558
       </para>
      </listitem>
     </varlistentry>
559

560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592
     <varlistentry>
      <term>EXAMINE_SUBCLASS</term>
      <listitem>
       <para>
       Changes the behaviour of SELECT so that it no longer automatically
       examines sub-classes. (See SELECT). By default a SELECT on a table
       will also return subclass tuples unless specifying ONLY tablename.
       Setting this returns postgres to the traditional behaviour of
       only returning subclasses when appending "*" to the tablename.
	<variablelist>
	 <varlistentry>
	  <term>ON</term>
	  <listitem>
	   <para>
       Returns SELECT to the behaviour of automatically returning
       results from sub-classes.
	   </para>
	  </listitem>
	 </varlistentry>
	
	 <varlistentry>
	  <term>OFF</term>
	  <listitem>
	   <para>
       Prevents SELECT from returning sub-classes unless the "*" follows the table name
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>
      </listitem>
     </varlistentry>

593
     <varlistentry>
594
      <term>ENABLE_SEQSCAN</term>
595 596
      <listitem>
       <para>
597 598 599 600
        Enables or disables the planner's use of sequential scan plan types.
	(It's not possible to suppress sequential scans entirely, but turning
	this variable OFF discourages the planner from using one if there is
	any other method available.)
601

602
	<variablelist>
603
	 <varlistentry>
604
	  <term>ON</term>
605 606
	  <listitem>
	   <para>
607
	    enables use of sequential scans (default setting).
608 609 610
	   </para>
	  </listitem>
	 </varlistentry>
611
	
612
	 <varlistentry>
613
	  <term>OFF</term>
614 615
	  <listitem>
	   <para>
616
	    disables use of sequential scans.
617 618 619 620
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
621
       </para>
622 623
      </listitem>
     </varlistentry>
624

625 626 627
     <varlistentry>
      <term>ENABLE_INDEXSCAN</term>
      <listitem>
628
       <para>
629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649
        Enables or disables the planner's use of index scan plan types.

	<variablelist>
	 <varlistentry>
	  <term>ON</term>
	  <listitem>
	   <para>
	    enables use of index scans (default setting).
	   </para>
	  </listitem>
	 </varlistentry>
	
	 <varlistentry>
	  <term>OFF</term>
	  <listitem>
	   <para>
	    disables use of index scans.
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
650 651 652
       </para>
      </listitem>
     </varlistentry>
653 654

     <varlistentry>
655
      <term>ENABLE_TIDSCAN</term>
656 657
      <listitem>
       <para>
658
        Enables or disables the planner's use of TID scan plan types.
659

660 661
	<variablelist>
	 <varlistentry>
662
	  <term>ON</term>
663 664
	  <listitem>
	   <para>
665
	    enables use of TID scans (default setting).
666 667 668
	   </para>
	  </listitem>
	 </varlistentry>
669 670 671 672 673 674 675 676 677 678 679 680 681
	
	 <varlistentry>
	  <term>OFF</term>
	  <listitem>
	   <para>
	    disables use of TID scans.
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>
      </listitem>
     </varlistentry>
682

683 684 685 686 687 688 689 690 691 692
     <varlistentry>
      <term>ENABLE_SORT</term>
      <listitem>
       <para>
        Enables or disables the planner's use of explicit sort steps.
	(It's not possible to suppress explicit sorts entirely, but turning
	this variable OFF discourages the planner from using one if there is
	any other method available.)

	<variablelist>
693
	 <varlistentry>
694
	  <term>ON</term>
695 696
	  <listitem>
	   <para>
697
	    enables use of sorts (default setting).
698 699 700
	   </para>
	  </listitem>
	 </varlistentry>
701 702 703 704 705 706 707 708 709 710 711 712 713
	
	 <varlistentry>
	  <term>OFF</term>
	  <listitem>
	   <para>
	    disables use of sorts.
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>
      </listitem>
     </varlistentry>
714

715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733
     <varlistentry>
      <term>ENABLE_NESTLOOP</term>
      <listitem>
       <para>
        Enables or disables the planner's use of nested-loop join plans.
	(It's not possible to suppress nested-loop joins entirely, but turning
	this variable OFF discourages the planner from using one if there is
	any other method available.)

	<variablelist>
	 <varlistentry>
	  <term>ON</term>
	  <listitem>
	   <para>
	    enables use of nested-loop joins (default setting).
	   </para>
	  </listitem>
	 </varlistentry>
	
734
	 <varlistentry>
735
	  <term>OFF</term>
736 737
	  <listitem>
	   <para>
738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758
	    disables use of nested-loop joins.
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term>ENABLE_MERGEJOIN</term>
      <listitem>
       <para>
        Enables or disables the planner's use of mergejoin plans.

	<variablelist>
	 <varlistentry>
	  <term>ON</term>
	  <listitem>
	   <para>
	    enables use of merge joins (default setting).
759 760 761
	   </para>
	  </listitem>
	 </varlistentry>
762
	
763
	 <varlistentry>
764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784
	  <term>OFF</term>
	  <listitem>
	   <para>
	    disables use of merge joins.
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term>ENABLE_HASHJOIN</term>
      <listitem>
       <para>
        Enables or disables the planner's use of hashjoin plans.

	<variablelist>
	 <varlistentry>
	  <term>ON</term>
785 786
	  <listitem>
	   <para>
787 788 789 790 791 792 793 794 795 796
	    enables use of hash joins (default setting).
	   </para>
	  </listitem>
	 </varlistentry>
	
	 <varlistentry>
	  <term>OFF</term>
	  <listitem>
	   <para>
	    disables use of hash joins.
797 798 799 800 801
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>
802 803
      </listitem>
     </varlistentry>
804

805 806 807
     <varlistentry>
      <term>GEQO</term>
      <listitem>
808
       <para>
809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842
	Sets the threshold for using the genetic optimizer algorithm.

	<variablelist>
	 <varlistentry>
	  <term>ON</term>
	  <listitem>
	   <para>
	    enables the genetic optimizer algorithm
	    for statements with 11 or more tables.
	    (This is also the DEFAULT setting.)
	   </para>
	  </listitem>
	 </varlistentry>

	 <varlistentry>
	  <term>ON=<replaceable class="parameter">#</replaceable></term>
	  <listitem>
	   <para>
	    Takes an integer argument to enable the genetic optimizer algorithm
	    for statements with <replaceable class="parameter">#</replaceable>
	    or more tables in the query.
	   </para>
	  </listitem>
	 </varlistentry>

	 <varlistentry>
	  <term>OFF</term>
	  <listitem>
	   <para>
	    disables the genetic optimizer algorithm.
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
843
       </para>
844

845
       <para>
846 847
	See the chapter on GEQO in the Programmer's Guide
	for more information about query optimization.
848 849
       </para>
       <para>
850 851 852
        If the PGGEQO environment variable is set in the frontend
	environment of a client based on libpq, libpq will automatically
	set GEQO to the value of PGGEQO during connection startup.
853 854 855 856
       </para>
      </listitem>
     </varlistentry>

857
     <varlistentry>
858
      <term>KSQO</term>
859
      <listitem>
860
       <para>
861 862 863 864 865 866 867 868 869 870
	<firstterm>Key Set Query Optimizer</firstterm> causes the query
	planner to convert queries whose WHERE clause contains many
	OR'ed AND clauses (such as "WHERE (a=1 AND b=2) OR (a=2 AND b=3) ...")
	into a UNION query.  This method can be faster than the default
	implementation, but it doesn't necessarily give exactly the same
	results, since UNION implicitly adds a SELECT DISTINCT clause to
	eliminate identical output rows.  KSQO is commonly used when
	working with products like <productname>MicroSoft
	Access</productname>, which tend to generate queries of this form.

871 872
	<variablelist>
	 <varlistentry>
873
	  <term>ON</term>
874 875
	  <listitem>
	   <para>
876 877 878 879 880 881
	    enables this optimization.
	   </para>
	  </listitem>
	 </varlistentry>
	
	 <varlistentry>
882
	  <term>OFF</term>
883 884
	  <listitem>
	   <para>
885
	    disables this optimization (default setting).
886 887 888 889 890
	   </para>
	  </listitem>
	 </varlistentry>
	 
	 <varlistentry>
891
	  <term>DEFAULT</term>
892 893
	  <listitem>
	   <para>
894
	    Equivalent to specifying <command>SET KSQO=OFF</command>.
895 896 897 898 899
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>
900

901
       <para>
902 903 904
        The KSQO algorithm used to be absolutely essential for queries
	with many OR'ed AND clauses, but in Postgres 7.0 and later
	the standard planner handles these queries fairly successfully.
905 906 907
       </para>
      </listitem>
     </varlistentry>
908

909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931
     <varlistentry>
      <term>MAX_EXPR_DEPTH</term>
      <listitem>
       <para>
        Sets the maximum expression nesting depth that the parser will
	accept.  The default value is high enough for any normal query,
	but you can raise it if you need to.  (But if you raise it too high,
	you run the risk of backend crashes due to stack overflow.)

	<variablelist>
	 <varlistentry>
	  <term><replaceable class="parameter">integer</replaceable></term>
	  <listitem>
	   <para>
	    Maximum depth.
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>
      </listitem>
     </varlistentry>

932 933 934
    </variablelist>
   </para>
  </refsect2>
935

936 937 938 939 940
  <refsect2 id="R2-SQL-SET-2">
   <refsect2info>
    <date>1998-09-24</date>
   </refsect2info>
   <title>
941
    Outputs
942 943
   </title>
   <para>
944
    
945 946
    <variablelist>
     <varlistentry>
947 948 949
      <term><computeroutput>
SET VARIABLE
       </computeroutput></term>
950 951
      <listitem>
       <para>
952
	Message returned if successful.
953 954 955 956
       </para>
      </listitem>
     </varlistentry>
     
957
     <varlistentry>
958
      <term><computeroutput>
959
NOTICE:  Bad value for <replaceable class="parameter">variable</replaceable> (<replaceable class="parameter">value</replaceable>)
960
       </computeroutput></term>
961 962 963
      <listitem>
       <para>
	If the command fails to set the specified variable.
964 965 966 967
       </para>
      </listitem>
     </varlistentry>
     
968
    </variablelist>
969
   </para>
970 971
  </refsect2>
 </refsynopsisdiv>
972
 
973 974 975 976 977
 <refsect1 id="R1-SQL-SET-1">
  <refsect1info>
   <date>1998-09-24</date>
  </refsect1info>
  <title>
978
   Description
979 980
  </title>
  <para>
981 982 983 984 985 986 987 988 989 990 991 992 993
   <command>SET</command> will modify configuration parameters for variable during
   a session.
  </para>
  <para>
   Current values can be obtained using <command>SHOW</command>, and values
   can be restored to the defaults using <command>RESET</command>.
   Parameters and values are case-insensitive. Note that the value
   field is always specified as a string, so is enclosed in
   single-quotes.
  </para>
  <para>
   <command>SET TIME ZONE</command> changes the session's
   default time zone offset.
994
   An SQL-session always begins with an initial default time zone
995 996 997 998 999
   offset.
   The <command>SET TIME ZONE</command> statement is used to change the default
   time zone offset for the current SQL session.
  </para>
  
1000 1001 1002 1003 1004
  <refsect2 id="R2-SQL-SET-3">
   <refsect2info>
    <date>1998-09-24</date>
   </refsect2info>
   <title>
1005
    Notes
1006 1007
   </title>
   <para>
1008 1009 1010 1011 1012 1013 1014
    The <command>SET <replaceable class="parameter">variable</replaceable></command>
    statement is a <productname>Postgres</productname> language extension.
   </para>
   <para>
    Refer to <command>SHOW</command> and <command>RESET</command> to 
    display or reset the current values.
   </para>
1015 1016
  </refsect2>
 </refsect1>
1017
 
1018 1019
 <refsect1 id="R1-SQL-SET-2">
  <title>
1020
   Usage
1021 1022
  </title>
  <para>
1023 1024
   Set the style of date to ISO (no quotes on the argument is required):

1025
   <programlisting>
1026
SET DATESTYLE TO ISO;
1027 1028
   </programlisting>

1029 1030
   Enable GEQO for queries with 4 or more tables (note the use of
   single quotes to handle the equal sign inside the value argument):
1031 1032

   <programlisting> 
T
Tom Lane 已提交
1033
SET GEQO = 'ON=4';
1034 1035 1036 1037 1038
   </programlisting>

   Set GEQO to default:

   <programlisting> 
1039
SET GEQO = DEFAULT;
1040 1041
   </programlisting>

1042 1043 1044
   Set the timezone for Berkeley, California, using double quotes to
   preserve the uppercase
   attributes of the time zone specifier:
1045

1046
<programlisting> 
1047
SET TIME ZONE "PST8PDT";
1048
SELECT CURRENT_TIMESTAMP AS today;
1049
   
1050 1051 1052 1053
         today
------------------------
 1998-03-31 07:41:21-08
</programlisting>
1054

1055 1056
   Set the timezone for Italy (note the required single or double quotes to handle 
   the special characters):
1057

1058
<programlisting> 
1059 1060
SET TIME ZONE 'Europe/Rome';
SELECT CURRENT_TIMESTAMP AS today;
1061
   
1062 1063 1064 1065
         today
------------------------
 1998-03-31 17:41:31+02
</programlisting>
1066
  </para>
1067
 </refsect1>
1068

1069 1070
 <refsect1 id="R1-SQL-SET-3">
  <title>
1071
   Compatibility
1072
  </title>
1073
  
1074 1075 1076 1077 1078
  <refsect2 id="R2-SQL-SET-4">
   <refsect2info>
    <date>1998-09-24</date>
   </refsect2info>
   <title>
1079
    SQL92
1080 1081
   </title>
   <para>
1082
    There is no general
1083
    <command>SET <replaceable class="parameter">variable</replaceable></command>
1084 1085 1086
    in <acronym>SQL92</acronym> (with the exception of
    <command>SET TRANSACTION ISOLATION LEVEL</command>).

1087 1088 1089 1090
    The <acronym>SQL92</acronym> syntax for <command>SET TIME ZONE</command>
    is slightly different,
    allowing only a single integer value for time zone specification:
    
1091 1092 1093
    <synopsis>
SET TIME ZONE { interval_value_expression | LOCAL }
    </synopsis>
1094 1095 1096
   </para>
  </refsect2>
 </refsect1>
1097
</refentry>
1098 1099 1100

<!-- Keep this comment at the end of the file
Local variables:
1101
mode:sgml
1102 1103 1104 1105 1106 1107 1108 1109 1110
sgml-omittag:nil
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"../reference.ced"
sgml-exposed-tags:nil
1111
sgml-local-catalogs:("/usr/lib/sgml/catalog")
1112 1113 1114
sgml-local-ecat-files:nil
End:
-->