set.sgml 25.5 KB
Newer Older
1
<!--
2
$Header: /cvsroot/pgsql/doc/src/sgml/ref/set.sgml,v 1.40 2000/04/14 15:17:28 thomas Exp $
3 4 5
Postgres documentation
-->

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

32 33 34 35 36
  <refsect2 id="R2-SQL-SET-1">
   <refsect2info>
    <date>1998-09-24</date>
   </refsect2info>
   <title>
37
    Inputs
38 39
   </title>
   <para>
40
		
41 42
    <variablelist>
     <varlistentry>
43
      <term><replaceable class="PARAMETER">variable</replaceable></term>
44
      <listitem>
45 46 47 48 49 50
       <para>
	Settable global parameter.
       </para>
      </listitem>
     </varlistentry>
     <varlistentry>
51
      <term><replaceable class="PARAMETER">value</replaceable></term>
52
      <listitem>
53
       <para>
54
	New value of parameter.  <option>DEFAULT</option> can be
55 56 57
	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.
58 59 60 61 62
       </para>
      </listitem>
     </varlistentry>
    </variablelist>
   </para>
63

64 65
   <para>
    The possible variables and allowed values are:
66
		
67 68
    <variablelist>
     <varlistentry>
69
      <term>CLIENT_ENCODING | NAMES</term>
70 71
      <listitem>
       <para>
72
	Sets the multi-byte client encoding. Parameters are:
73
	
74 75
	<variablelist>
	 <varlistentry>
76
	  <term><replaceable class="parameter">value</replaceable></term>
77 78 79 80 81 82 83 84 85 86 87 88
	  <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>
89 90
	This option is only available if MULTIBYTE support was enabled
	during the configure step of building Postgres.
91 92 93 94 95
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
96
      <term>DATESTYLE</term>
97 98
      <listitem>
       <para>
99 100 101
	Set the date/time representation style. Affects the output format,
	and in some cases it can affect the interpretation of input.

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

       <para>
171
	Date format initialization may be done by:
172 173
	<simplelist>
	 <member>
174
	  Setting the <envar>PGDATESTYLE</envar> environment variable.
175 176 177
	  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.
178 179
	 </member>
	 <member>
180
	  Running postmaster using the option <option>-o -e</option> to set
181
	  dates to the <literal>European</literal> convention.
182
	  Note that this affects only some combinations of date styles; for example
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205
	  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>
206
      <term>SEED</term>
207 208 209 210 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
      <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>
244
      <term>SERVER_ENCODING</term>
245 246
      <listitem>
       <para>
247
	Sets the multi-byte server encoding to:
248 249 250
	
	<variablelist>
	 <varlistentry>
251
	  <term><replaceable class="parameter">value</replaceable></term>
252 253
	  <listitem>
	   <para>
254
	    The identifying value for the server encoding.
255 256 257 258 259
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>
260

261
       <para>
262 263
	This option is only available if MULTIBYTE support was enabled
	during the configure step of building Postgres.
264
       </para>
265 266 267 268
      </listitem>
     </varlistentry>

     <varlistentry>
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309
      <term>CONSTRAINT</term>
      <listitem>
       <para>
	SET CONSTRAINTS is the SQL3 specified command to  change  the
	default behaviour of constraints with respect to deferring in the current
	transaction. Allowed parameters are:

	<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>
	In deferred mode, the actual check of the constraint is  held
	back  until  either its mode is explicitly set to <option>IMMEDIATE</option>,
	or until COMMIT.  This is actually only done for foreign  key
	constraints,  so  it  does  not  apply  to  UNIQUE  or  other
	constraints.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term>TIME ZONE</term>
310
      <term>TIMEZONE</term>
311 312 313 314 315 316 317 318
      <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:
319
				
320 321
	<variablelist>
	 <varlistentry>
322
	  <term>PST8PDT</term>
323 324 325 326 327 328 329
	  <listitem>
	   <para>
	    set the timezone for California
	   </para>
	  </listitem>
	 </varlistentry>
	 <varlistentry>
330
	  <term>Portugal</term>
331 332 333 334 335 336 337
	  <listitem>
	   <para>
	    set time zone for Portugal.
	   </para>
	  </listitem>
	 </varlistentry>
	 <varlistentry>
338
	  <term>'Europe/Rome'</term>
339 340 341 342 343 344 345
	  <listitem>
	   <para>
	    set time zone for Italy.
	   </para>
	  </listitem>
	 </varlistentry>
	 <varlistentry>
346
	  <term>DEFAULT</term>
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365
	  <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>
366 367 368 369 370
       <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>
371 372
      </listitem>
     </varlistentry>
373 374

     <varlistentry>
375
      <term>TRANSACTION ISOLATION LEVEL</term>
376 377 378 379 380 381
      <listitem>
       <para>
	Sets the isolation level for the current transaction.
	
	<variablelist>
	 <varlistentry>
382
	  <term>READ COMMITTED</term>
383 384
	  <listitem>
	   <para>
V
Vadim B. Mikheev 已提交
385 386
	    The current transaction queries read only rows committed
	    before a query began. READ COMMITTED is the default.
387
	   </para>
V
Vadim B. Mikheev 已提交
388 389

	   <note>
390
	   <para>
V
Vadim B. Mikheev 已提交
391 392
	    <acronym>SQL92</acronym> standard requires 
	    SERIALIZABLE to be the default isolation level.
393
	   </para>
V
Vadim B. Mikheev 已提交
394
	   </note>
395 396 397 398
	  </listitem>
	 </varlistentry>
	 
	 <varlistentry>
399
	  <term>SERIALIZABLE</term>
400 401
	  <listitem>
	   <para>
V
Vadim B. Mikheev 已提交
402 403 404 405
	    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. 
406 407 408
	   </para>
	  </listitem>
	 </varlistentry>
V
Vadim B. Mikheev 已提交
409
	 
410 411 412 413
	</variablelist>
       </para>
      </listitem>
     </varlistentry>
414 415
    </variablelist>
   </para>
416

417 418 419 420 421 422
   <para>
    There are also several internal or optimization
    parameters which can be specified
    by the <command>SET</command> command:
    
    <variablelist>
423
     <varlistentry>
B
Bruce Momjian 已提交
424
      <term>PG_OPTIONS</term>
425 426 427 428 429 430 431
      <listitem>
       <para>
        Sets various backend parameters.
       </para>
      </listitem>
     </varlistentry>
    
432
     <varlistentry>
433
      <term>RANDOM_PAGE_COST</term>
434 435
      <listitem>
       <para>
436 437 438
        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.
439 440 441
	
	<variablelist>
	 <varlistentry>
442
	  <term><replaceable class="parameter">float8</replaceable></term>
443 444
	  <listitem>
	   <para>
445 446
	    Set the cost of a random page access
	    to the specified floating-point value.
447 448 449
	   </para>
	  </listitem>
	 </varlistentry>
450 451 452 453 454 455 456 457 458 459 460 461 462 463
	</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>
464
	 <varlistentry>
465
	  <term><replaceable class="parameter">float8</replaceable></term>
466 467
	  <listitem>
	   <para>
468 469
	    Set the cost of per-tuple CPU processing
	    to the specified floating-point value.
470 471 472 473 474
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>
475 476 477 478 479 480
      </listitem>
     </varlistentry>
    
     <varlistentry>
      <term>CPU_INDEX_TUPLE_COST</term>
      <listitem>
481
       <para>
482 483 484 485 486 487 488 489 490 491 492 493 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
        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>
544 545 546
       </para>
      </listitem>
     </varlistentry>
547

548
     <varlistentry>
549
      <term>ENABLE_SEQSCAN</term>
550 551
      <listitem>
       <para>
552 553 554 555
        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.)
556

557
	<variablelist>
558
	 <varlistentry>
559
	  <term>ON</term>
560 561
	  <listitem>
	   <para>
562
	    enables use of sequential scans (default setting).
563 564 565
	   </para>
	  </listitem>
	 </varlistentry>
566
	
567
	 <varlistentry>
568
	  <term>OFF</term>
569 570
	  <listitem>
	   <para>
571
	    disables use of sequential scans.
572 573 574 575
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
576
       </para>
577 578
      </listitem>
     </varlistentry>
579

580 581 582
     <varlistentry>
      <term>ENABLE_INDEXSCAN</term>
      <listitem>
583
       <para>
584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604
        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>
605 606 607
       </para>
      </listitem>
     </varlistentry>
608 609

     <varlistentry>
610
      <term>ENABLE_TIDSCAN</term>
611 612
      <listitem>
       <para>
613
        Enables or disables the planner's use of TID scan plan types.
614

615 616
	<variablelist>
	 <varlistentry>
617
	  <term>ON</term>
618 619
	  <listitem>
	   <para>
620
	    enables use of TID scans (default setting).
621 622 623
	   </para>
	  </listitem>
	 </varlistentry>
624 625 626 627 628 629 630 631 632 633 634 635 636
	
	 <varlistentry>
	  <term>OFF</term>
	  <listitem>
	   <para>
	    disables use of TID scans.
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>
      </listitem>
     </varlistentry>
637

638 639 640 641 642 643 644 645 646 647
     <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>
648
	 <varlistentry>
649
	  <term>ON</term>
650 651
	  <listitem>
	   <para>
652
	    enables use of sorts (default setting).
653 654 655
	   </para>
	  </listitem>
	 </varlistentry>
656 657 658 659 660 661 662 663 664 665 666 667 668
	
	 <varlistentry>
	  <term>OFF</term>
	  <listitem>
	   <para>
	    disables use of sorts.
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>
      </listitem>
     </varlistentry>
669

670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688
     <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>
	
689
	 <varlistentry>
690
	  <term>OFF</term>
691 692
	  <listitem>
	   <para>
693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713
	    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).
714 715 716
	   </para>
	  </listitem>
	 </varlistentry>
717
	
718
	 <varlistentry>
719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739
	  <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>
740 741
	  <listitem>
	   <para>
742 743 744 745 746 747 748 749 750 751
	    enables use of hash joins (default setting).
	   </para>
	  </listitem>
	 </varlistentry>
	
	 <varlistentry>
	  <term>OFF</term>
	  <listitem>
	   <para>
	    disables use of hash joins.
752 753 754 755 756
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>
757 758
      </listitem>
     </varlistentry>
759

760 761 762
     <varlistentry>
      <term>GEQO</term>
      <listitem>
763
       <para>
764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797
	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>
798
       </para>
799

800
       <para>
801 802
	See the chapter on GEQO in the Programmer's Guide
	for more information about query optimization.
803 804
       </para>
       <para>
805 806 807
        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.
808 809 810 811
       </para>
      </listitem>
     </varlistentry>

812
     <varlistentry>
813
      <term>KSQO</term>
814
      <listitem>
815
       <para>
816 817 818 819 820 821 822 823 824 825
	<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.

826 827
	<variablelist>
	 <varlistentry>
828
	  <term>ON</term>
829 830
	  <listitem>
	   <para>
831 832 833 834 835 836
	    enables this optimization.
	   </para>
	  </listitem>
	 </varlistentry>
	
	 <varlistentry>
837
	  <term>OFF</term>
838 839
	  <listitem>
	   <para>
840
	    disables this optimization (default setting).
841 842 843 844 845
	   </para>
	  </listitem>
	 </varlistentry>
	 
	 <varlistentry>
846
	  <term>DEFAULT</term>
847 848
	  <listitem>
	   <para>
849
	    Equivalent to specifying <command>SET KSQO=OFF</command>.
850 851 852 853 854
	   </para>
	  </listitem>
	 </varlistentry>
	</variablelist>
       </para>
855

856
       <para>
857 858 859
        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.
860 861 862
       </para>
      </listitem>
     </varlistentry>
863

864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886
     <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>

887 888 889
    </variablelist>
   </para>
  </refsect2>
890

891 892 893 894 895
  <refsect2 id="R2-SQL-SET-2">
   <refsect2info>
    <date>1998-09-24</date>
   </refsect2info>
   <title>
896
    Outputs
897 898
   </title>
   <para>
899
    
900 901
    <variablelist>
     <varlistentry>
902 903 904
      <term><computeroutput>
SET VARIABLE
       </computeroutput></term>
905 906
      <listitem>
       <para>
907
	Message returned if successful.
908 909 910 911
       </para>
      </listitem>
     </varlistentry>
     
912
     <varlistentry>
913 914 915
      <term><computeroutput>
WARN:  Bad value for <replaceable class="parameter">variable</replaceable> (<replaceable class="parameter">value</replaceable>)
       </computeroutput></term>
916 917 918
      <listitem>
       <para>
	If the command fails to set the specified variable.
919 920 921 922
       </para>
      </listitem>
     </varlistentry>
     
923
    </variablelist>
924
   </para>
925 926
  </refsect2>
 </refsynopsisdiv>
927
 
928 929 930 931 932
 <refsect1 id="R1-SQL-SET-1">
  <refsect1info>
   <date>1998-09-24</date>
  </refsect1info>
  <title>
933
   Description
934 935
  </title>
  <para>
936 937 938 939 940 941 942 943 944 945 946 947 948
   <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.
949
   An SQL-session always begins with an initial default time zone
950 951 952 953 954
   offset.
   The <command>SET TIME ZONE</command> statement is used to change the default
   time zone offset for the current SQL session.
  </para>
  
955 956 957 958 959
  <refsect2 id="R2-SQL-SET-3">
   <refsect2info>
    <date>1998-09-24</date>
   </refsect2info>
   <title>
960
    Notes
961 962
   </title>
   <para>
963 964 965 966 967 968 969
    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>
970 971
  </refsect2>
 </refsect1>
972
 
973 974
 <refsect1 id="R1-SQL-SET-2">
  <title>
975
   Usage
976 977
  </title>
  <para>
978 979
   Set the style of date to ISO (no quotes on the argument is required):

980
   <programlisting>
981
SET DATESTYLE TO ISO;
982 983
   </programlisting>

984 985
   Enable GEQO for queries with 4 or more tables (note the use of
   single quotes to handle the equal sign inside the value argument):
986 987

   <programlisting> 
T
Tom Lane 已提交
988
SET GEQO = 'ON=4';
989 990 991 992 993
   </programlisting>

   Set GEQO to default:

   <programlisting> 
994
SET GEQO = DEFAULT;
995 996
   </programlisting>

997 998 999
   Set the timezone for Berkeley, California, using double quotes to
   preserve the uppercase
   attributes of the time zone specifier:
1000

1001
<programlisting> 
1002
SET TIME ZONE "PST8PDT";
1003
SELECT CURRENT_TIMESTAMP AS today;
1004
   
1005 1006 1007 1008
         today
------------------------
 1998-03-31 07:41:21-08
</programlisting>
1009

1010 1011
   Set the timezone for Italy (note the required single or double quotes to handle 
   the special characters):
1012

1013
<programlisting> 
1014 1015
SET TIME ZONE 'Europe/Rome';
SELECT CURRENT_TIMESTAMP AS today;
1016
   
1017 1018 1019 1020
         today
------------------------
 1998-03-31 17:41:31+02
</programlisting>
1021
  </para>
1022
 </refsect1>
1023

1024 1025
 <refsect1 id="R1-SQL-SET-3">
  <title>
1026
   Compatibility
1027
  </title>
1028
  
1029 1030 1031 1032 1033
  <refsect2 id="R2-SQL-SET-4">
   <refsect2info>
    <date>1998-09-24</date>
   </refsect2info>
   <title>
1034
    SQL92
1035 1036
   </title>
   <para>
1037
    There is no general
1038
    <command>SET <replaceable class="parameter">variable</replaceable></command>
1039 1040 1041
    in <acronym>SQL92</acronym> (with the exception of
    <command>SET TRANSACTION ISOLATION LEVEL</command>).

1042 1043 1044 1045
    The <acronym>SQL92</acronym> syntax for <command>SET TIME ZONE</command>
    is slightly different,
    allowing only a single integer value for time zone specification:
    
1046 1047 1048
    <synopsis>
SET TIME ZONE { interval_value_expression | LOCAL }
    </synopsis>
1049 1050 1051
   </para>
  </refsect2>
 </refsect1>
1052
</refentry>
1053 1054 1055

<!-- Keep this comment at the end of the file
Local variables:
1056
mode:sgml
1057 1058 1059 1060 1061 1062 1063 1064 1065
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
1066
sgml-local-catalogs:("/usr/lib/sgml/catalog")
1067 1068 1069
sgml-local-ecat-files:nil
End:
-->