Skip to content

Commit 1cfb56a

Browse files
committed
Fixes for pghitnplan docs by Lakhin
1 parent e0ddf66 commit 1cfb56a

File tree

1 file changed

+53
-55
lines changed

1 file changed

+53
-55
lines changed

doc/src/sgml/pghintplan.sgml

Lines changed: 53 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<sect1 id="pg-hint-plan">
2-
<title>pg_hint_plan 1.1.3</title>
2+
<title>pg_hint_plan</title>
33
<sect2 id="pg-hint-plan-name">
44
<title>Name</title>
55
<para>
@@ -10,11 +10,11 @@
1010
<sect2 id="pg-hint-plan-synopsis">
1111
<title>Synopsis</title>
1212
<para>
13-
PostgreSQL uses cost based optimizer, which utilizes data
13+
PostgreSQL uses cost-based optimizer, which utilizes data
1414
statistics, not static rules. The planner (optimizer) esitimates
1515
costs of each possible execution plans for a SQL statement then
1616
the execution plan with the lowest cost finally be executed. The
17-
planner does its best to select the best best execution plan, but
17+
planner does its best to select the best execution plan, but
1818
not perfect, since it doesn't count some properties of the data,
1919
for example, correlation between columns.
2020
</para>
@@ -32,13 +32,13 @@
3232
pg_hint_plan reads hinting phrases in a comment of special form
3333
given with the target SQL statement. The special form is
3434
beginning by the character sequence <quote>/*+</quote> and ends
35-
with <quote>*/</quote>. Hint phrases are consists of hint name
35+
with <quote>*/</quote>. Hint phrases consist of hint name
3636
and following parameters enclosed by parentheses and delimited
3737
by spaces. Each hinting phrases can be delimited by new lines
3838
for readability.
3939
</para>
4040
<para>
41-
In the example below , hash join is selected as the joning
41+
In the example below, hash join is selected as the joining
4242
method and scanning pgbench_accounts by sequential scan method.
4343
</para>
4444
<programlisting>
@@ -67,8 +67,8 @@ postgres=#
6767
<sect3 id="pg-hint-plan-hint-group">
6868
<title>The types of hints</title>
6969
<para>
70-
Hinting phrases are classified into four types based on what
71-
kind of object they can affect. Scaning methods, join methods,
70+
Hinting phrases are classified into five types based on what
71+
kind of object they can affect: scanning methods, join methods,
7272
joining order, row number correction and GUC setting. You will
7373
see the lists of hint phrases of each type in Hint list (See <xref linkend="pg-hint-plan-hint-list">).
7474
</para>
@@ -77,15 +77,15 @@ postgres=#
7777
<para>
7878
Scan method hints enforce the scanning method on the table
7979
specified as parameter. pg_hint_plan recognizes the target
80-
table by alias names if any. They are <quote>SeqScan</quote> ,
80+
table by alias names if any. They are <quote>SeqScan</quote>,
8181
<quote>IndexScan</quote> and so on.
8282
</para>
8383
<para>
8484
Scan hints are effective on ordinary tables, inheritance
8585
tables, UNLOGGED tables, temporary tables and system catalogs.
8686
It cannot be applicable on external(foreign) tables, table
87-
functions, VALUES command results, CTEs, Views and
88-
Sub-enquiries.
87+
functions, VALUES command results, CTEs, views and
88+
subqueries.
8989
</para>
9090
</sect4>
9191
<sect4>
@@ -98,7 +98,7 @@ postgres=#
9898
Ordinary tables, inheritance tables, UNLOGGED tables,
9999
temporary tables, external (foreign) tables, system catalogs,
100100
table functions, VALUES command results and CTEs are allowed
101-
to be in the parameter list. But views and sub query are not.
101+
to be in the parameter list. But views and subqueries are not.
102102
</para>
103103
</sect4>
104104
<sect4>
@@ -121,9 +121,8 @@ postgres=#
121121
<title>GUC parameters temporarily setting</title>
122122
<para>
123123
<quote>Set</quote> hint changes GUC parameters just while
124-
planning. GUC parameter shown in
125-
<ulink url="http://www.postgresql.org/docs/current/static/runtime-config-query.html">Query
126-
Planning</ulink> can have the expected effects on planning
124+
planning. GUC parameter shown in <xref linkend="runtime-config-query-constants">
125+
can have the expected effects on planning
127126
unless any other hint conflicts with the planner method
128127
configuration parameters. The last one among hints on the same
129128
GUC parameter makes effect. GUC parameters for pg_hint_plan are also settable by this
@@ -136,22 +135,22 @@ postgres=#
136135
<title>GUC parameters for pg_hint_plan</title>
137136
<para>
138137
GUC parameters below affect the behavior of
139-
pg_hint_planpg_hint_plan.
138+
pg_hint_plan.
140139
</para>
141140
<para>
142141
Parameter name
143142
</para>
144143
<para>
145-
discription
144+
Description
146145
</para>
147146
<para>
148-
Default
147+
Default value
149148
</para>
150149
<para>
151150
pg_hint_plan.enable_hint
152151
</para>
153152
<para>
154-
Enbles or disables the function of pg_hint_plan.
153+
Enables or disables the function of pg_hint_plan.
155154
</para>
156155
<para>
157156
on
@@ -179,8 +178,7 @@ postgres=#
179178
</para>
180179
<para>
181180
PostgreSQL 9.1 requires a custom variable class to be defined
182-
for those GUC parameters. See
183-
<ulink url="http://www.postgresql.org/docs/9.1/static/runtime-config-custom.html#GUC-CUSTOM-VARIABLE-CLASSES">custom_variable_classes</ulink>
181+
for those GUC parameters. See <xref linkend="runtime-config-custom">
184182
for details.
185183
</para>
186184
</sect3>
@@ -191,9 +189,9 @@ postgres=#
191189
This section describes the installation steps.
192190
</para>
193191
<sect3 id="pg-hint-plan-build">
194-
<title>building binary module</title>
192+
<title>Building binary module</title>
195193
<para>
196-
Simplly run <quote>make</quote> in the top of the source tree,
194+
Simply run <quote>make</quote> in the top of the source tree,
197195
then <quote>make install</quote> as appropriate user. The PATH
198196
environment variable should be set properly for the target
199197
PostgreSQL for this process.
@@ -207,10 +205,10 @@ $ su
207205
</programlisting>
208206
</sect3>
209207
<sect3 id="pg-hint-plan-hint-load">
210-
<title>Loding pg_hint_plan</title>
208+
<title>Loading pg_hint_plan</title>
211209
<para>
212210
Basically pg_hint_plan does not requires CREATE EXTENSION.
213-
Simplly loading it by LOAD command will activate it and of
211+
Simply loading it by LOAD command will activate it and of
214212
course you can load it globally by setting
215213
shared_preload_libraries in postgresql.conf. Or you might be
216214
interested in ALTER USER SET/ALTER DATABASE SET for automatic
@@ -222,13 +220,13 @@ LOAD
222220
postgres=#
223221
</programlisting>
224222
<para>
225-
Do CREATE EXTENSION and SET pg_hint_plan.enable_hint_tables TO
226-
on if you are planning to hint tables.
223+
Do CREATE EXTENSION and SET pg_hint_plan.enable_hint_table TO
224+
<literal>on</literal> if you are planning to use hint table.
227225
</para>
228226
</sect3>
229227
</sect2>
230228
<sect2 id="pg-hint-plan-uninstall">
231-
<title>Unistallation</title>
229+
<title>Uninstallation</title>
232230
<para>
233231
<quote>make uninstall</quote> in the top directory of source tree
234232
will uninstall the installed files if you installed from the
@@ -249,7 +247,7 @@ $ su
249247
<title>Scan method hints</title>
250248
<para>
251249
Scan hints have basically has one parameter to specify the
252-
target object. This additional parameter for scans using indexes
250+
target object. The additional parameter for scans using indexes
253251
is preferable index name. The target object should be specified
254252
by its alias name if any. In the following example, table1 is
255253
scanned by sequential scan and table2 is scanned using the
@@ -270,7 +268,7 @@ postgres-# SELECT * FROM table1 t1 JOIN table table2 t2 ON (t1.key = t2.key);
270268
parameters. If three objects are specified, the hint will be
271269
applied when joining any one of them after joining other two
272270
objects. In the following example, table1 and table2 are joined
273-
fisrt using nested loop and the result is joined against table3
271+
first using nested loop and the result is joined against table3
274272
using merge join.
275273
</para>
276274
<programlisting>
@@ -287,11 +285,11 @@ postgres-# JOIN table table3 t3 ON (t2.key = t3.key);
287285
<sect3>
288286
<title>Joining order hints</title>
289287
<para>
290-
Although there might be the case that table2 and 3 are joined
288+
Although there might be the case that table2 and table3 are joined
291289
first and table1 after that and the NestLoop hint won't be in
292290
effect after all. <quote>Leading</quote> hint enforces the
293291
joining order for the cases. The Leading hint in the above
294-
example enforces the joining order to table1, 2, 3 then both
292+
example enforces the joining order to table1, table2, table3 then both
295293
join method hints will be effective.
296294
</para>
297295
<para>
@@ -380,11 +378,11 @@ postgres=#
380378
</programlisting>
381379
</sect3>
382380
<sect3>
383-
<title>Escaping special chacaters in object names</title>
381+
<title>Escaping special characters in object names</title>
384382
<para>
385383
The objects as the hint parameter should be enclosed by double
386384
quotes if they includes parentheses, double quotes and white
387-
spaces. The escaping rule is the same as PostgreSQL.
385+
spaces. The escaping rule is the same as <productname>&productname;</productname>.
388386
</para>
389387
</sect3>
390388
<sect3>
@@ -450,20 +448,20 @@ postgres=#
450448
<sect3>
451449
<title>Hinting on inheritance children</title>
452450
<para>
453-
Inheritnce children cannot be hinted individually. They share
451+
Inheritance children cannot be hinted individually. They share
454452
the same hints on their parent.
455453
</para>
456454
</sect3>
457455
<sect3>
458456
<title>Setting pg_hint_plan parameters by Set hints</title>
459457
<para>
460-
pg_hint_plan paramters changes the behavior of itself so some
458+
pg_hint_plan parameters changes the behavior of itself so some
461459
parameters doesn't work as expected.
462460
</para>
463461
<itemizedlist spacing="compact">
464462
<listitem>
465463
<para>
466-
Hints to change enable_hint, enable_hint_tables are ignored,
464+
Hints to change enable_hint, enable_hint_table are ignored,
467465
but they are reported as <quote>used hints</quote> in debug
468466
logs.
469467
</para>
@@ -480,11 +478,11 @@ postgres=#
480478
<sect2 id="pg-hint-plan-technics">
481479
<title>Technics to hint on desired targets</title>
482480
<sect3>
483-
<title>Hinting on objecects implicitly used in the target
481+
<title>Hinting on objects implicitly used in the target
484482
query</title>
485483
<para>
486484
Hints are effective on any objects with the target name even if
487-
they aren't aparent in the query, specifically objects in views.
485+
they aren't apparent in the query, specifically objects in views.
488486
For that reason, you should create different views in which
489487
targetted objects have distinct aliases if you want to hint them
490488
differently from the first view.
@@ -493,11 +491,11 @@ postgres=#
493491
In the following examples, the first query is assigning the same
494492
name <quote>t1</quote> on the two occurrences of the table1 so
495493
the hint SeqScan(t1) affects both scans. On the other hand the
496-
second assignes the different name <quote>t3</quote> on the one
494+
second query assigns the different name <quote>t3</quote> on the one
497495
of them so the hint affects only on the rest one.
498496
</para>
499497
<para>
500-
This mechanism also applies on rewritten queries by rules.
498+
This mechanism also applies on queries rewritten by rules.
501499
</para>
502500
<programlisting>
503501
postgres=# CREATE VIEW view1 AS SELECT * FROM table1 t1;
@@ -526,19 +524,19 @@ postgres=# EXPLAIN SELECT * FROM table1 t3 JOIN view1 t2 ON (t1.key = t2.key) WH
526524
</programlisting>
527525
</sect3>
528526
<sect3>
529-
<title>Hinting on the hinheritance children</title>
527+
<title>Hinting on the inheritance children</title>
530528
<para>
531529
Hints targeted on inheritance parents automatically affect on
532530
all their own children. Child tables cannot have their own hint
533531
specified.
534532
</para>
535533
</sect3>
536534
<sect3>
537-
<title>Scope of hints on multistatement</title>
535+
<title>Scope of hints on multi-statement</title>
538536
<para>
539-
One multistatement description can have exactly one hint comment
537+
One multi-statement description can have exactly one hint comment
540538
and the hints affects all of the individual statement in the
541-
multistatement. Notice that the seemingly multistatement on the
539+
multi-statement. Notice that the seemingly multi-statement on the
542540
interactive interface of psql is internally a sequence of single
543541
statements so hints affects only on the statement just
544542
following. Conversely, every single statement have their own
@@ -548,7 +546,7 @@ postgres=# EXPLAIN SELECT * FROM table1 t3 JOIN view1 t2 ON (t1.key = t2.key) WH
548546
<sect3>
549547
<title>Subqueries in some contexts</title>
550548
<para>
551-
Subqueries in the following context also can be hinted.
549+
Subqueries in the following contexts also can be hinted.
552550
</para>
553551
<programlisting>
554552
IN (SELECT ... {LIMIT | OFFSET ...} ...)
@@ -581,7 +579,7 @@ postgres=# WHERE aid IN (SELECT bid FROM pgbench_accounts a2 LIMIT 10);
581579
<sect3>
582580
<title>Using IndexOnlyScan hint (PostgreSQL 9.2 and later)</title>
583581
<para>
584-
You shoud explicitly specify an index that can perform index
582+
You should explicitly specify an index that can perform index
585583
only scan if you put IndexOnlyScan hint on a table that have
586584
other indexes that cannot perform index only scan. Or
587585
pg_hint_plan may select them.
@@ -591,7 +589,7 @@ postgres=# WHERE aid IN (SELECT bid FROM pgbench_accounts a2 LIMIT 10);
591589
<title>Precaution points for NoIndexScan hint (PostgreSQL 9.2 and
592590
later)</title>
593591
<para>
594-
NoIndexScan hint involes NoIndexOnlyScan.
592+
NoIndexScan hint involves NoIndexOnlyScan.
595593
</para>
596594
</sect3>
597595
</sect2>
@@ -631,8 +629,8 @@ postgres=# WHERE aid IN (SELECT bid FROM pgbench_accounts a2 LIMIT 10);
631629
<title>Nested comments</title>
632630
<para>
633631
Hint comment cannot include another block comment within. If
634-
pg_hint_plan finds it, differently from other erros, it stops
635-
parsing and abandans all hints already parsed. This kind of
632+
pg_hint_plan finds it, differently from other errors, it stops
633+
parsing and abandons all hints already parsed. This kind of
636634
error is reported in the same manner as other errors.
637635
</para>
638636
</sect3>
@@ -683,10 +681,10 @@ postgres=# WHERE aid IN (SELECT bid FROM pgbench_accounts a2 LIMIT 10);
683681
<sect3>
684682
<title>Effects on query fingerprints</title>
685683
<para>
686-
The same queries with different commnets yields the same
684+
The same queries with different comments yields the same
687685
fingerprint by pg_stat_statements on PostgreSQL 9.2 and later,
688686
but they yield different fingerprints on 9.1 and earlier, so the
689-
same queires with different hints are summerized as separate
687+
same queries with different hints are summarized as separate
690688
queries on such versions.
691689
</para>
692690
</sect3>
@@ -730,11 +728,11 @@ postgres=# WHERE aid IN (SELECT bid FROM pgbench_accounts a2 LIMIT 10);
730728
<para>IndexScan(table[ index...])</para>
731729
<para>Forces index scan on the table. Restricts to specified indexes if any.</para>
732730
<para>IndexOnlyScan(table[ index...])</para>
733-
<para>Forces index only scan on the table. Rstricts to specfied indexes
731+
<para>Forces index only scan on the table. Restricts to specfied indexes
734732
if any. Index scan may be used if index only scan is not
735733
available. Available for PostgreSQL 9.2 and later.</para>
736734
<para>BitmapScan(table[ index...])</para>
737-
<para>Forces bitmap scan on the table. Restoricts to specfied indexes if any.</para>
735+
<para>Forces bitmap scan on the table. Restricts to specfied indexes if any.</para>
738736
<para>NoSeqScan(table)</para>
739737
<para>Forces not to do sequential scan on the table.</para>
740738
<para>NoTidScan(table)</para>
@@ -772,8 +770,8 @@ postgres=# WHERE aid IN (SELECT bid FROM pgbench_accounts a2 LIMIT 10);
772770
<para>Rows(table table[ table...] correction)</para>
773771
<para>Corrects row number of a result of the joins consist of the
774772
specfied tables. The available correction methods are absolute
775-
(#&amp;ltn&gt;), addition (+&amp;ltn&gt;), subtract
776-
(-&amp;ltn&gt;) and multiplication (*&amp;ltn&gt;). &amp;ltn&gt;
773+
(#&lt;n&gt;), addition (+&lt;n&gt;), subtract
774+
(-&lt;n&gt;) and multiplication (*&lt;n&gt;). &lt;n&gt;
777775
should be a string that strtod() can read.</para>
778776
<para>GUC</para>
779777
<para>Set(GUC-param value)</para>

0 commit comments

Comments
 (0)