88 </indexterm>
99
1010 <para>
11- <productname>PostgreSQL</productname> can devise query plans which can leverage
11+ <productname>PostgreSQL</productname> can devise query plans that can leverage
1212 multiple CPUs in order to answer queries faster. This feature is known
1313 as parallel query. Many queries cannot benefit from parallel query, either
1414 due to limitations of the current implementation or because there is no
15- imaginable query plan which is any faster than the serial query plan.
15+ imaginable query plan that is any faster than the serial query plan.
1616 However, for queries that can benefit, the speedup from parallel query
1717 is often very significant. Many queries can run more than twice as fast
1818 when using parallel query, and some queries can run four times faster or
2727
2828 <para>
2929 When the optimizer determines that parallel query is the fastest execution
30- strategy for a particular query, it will create a query plan which includes
30+ strategy for a particular query, it will create a query plan that includes
3131 a <firstterm>Gather</firstterm> or <firstterm>Gather Merge</firstterm>
3232 node. Here is a simple example:
3333
@@ -59,7 +59,7 @@ EXPLAIN SELECT * FROM pgbench_accounts WHERE filler LIKE '%x%';
5959 <para>
6060 <link linkend="using-explain">Using EXPLAIN</link>, you can see the number of
6161 workers chosen by the planner. When the <literal>Gather</literal> node is reached
62- during query execution, the process which is implementing the user's
62+ during query execution, the process that is implementing the user's
6363 session will request a number of <link linkend="bgworker">background
6464 worker processes</link> equal to the number
6565 of workers chosen by the planner. The number of background workers that
@@ -79,7 +79,7 @@ EXPLAIN SELECT * FROM pgbench_accounts WHERE filler LIKE '%x%';
7979 </para>
8080
8181 <para>
82- Every background worker process which is successfully started for a given
82+ Every background worker process that is successfully started for a given
8383 parallel query will execute the parallel portion of the plan. The leader
8484 will also execute that portion of the plan, but it has an additional
8585 responsibility: it must also read all of the tuples generated by the
@@ -88,7 +88,7 @@ EXPLAIN SELECT * FROM pgbench_accounts WHERE filler LIKE '%x%';
8888 worker, speeding up query execution. Conversely, when the parallel portion
8989 of the plan generates a large number of tuples, the leader may be almost
9090 entirely occupied with reading the tuples generated by the workers and
91- performing any further processing steps which are required by plan nodes
91+ performing any further processing steps that are required by plan nodes
9292 above the level of the <literal>Gather</literal> node or
9393 <literal>Gather Merge</literal> node. In such cases, the leader will
9494 do very little of the work of executing the parallel portion of the plan.
@@ -109,7 +109,7 @@ EXPLAIN SELECT * FROM pgbench_accounts WHERE filler LIKE '%x%';
109109 <title>When Can Parallel Query Be Used?</title>
110110
111111 <para>
112- There are several settings which can cause the query planner not to
112+ There are several settings that can cause the query planner not to
113113 generate a parallel query plan under any circumstances. In order for
114114 any parallel query plans whatsoever to be generated, the following
115115 settings must be configured as indicated.
@@ -119,7 +119,7 @@ EXPLAIN SELECT * FROM pgbench_accounts WHERE filler LIKE '%x%';
119119 <listitem>
120120 <para>
121121 <xref linkend="guc-max-parallel-workers-per-gather"/> must be set to a
122- value which is greater than zero. This is a special case of the more
122+ value that is greater than zero. This is a special case of the more
123123 general principle that no more workers should be used than the number
124124 configured via <varname>max_parallel_workers_per_gather</varname>.
125125 </para>
@@ -144,8 +144,8 @@ EXPLAIN SELECT * FROM pgbench_accounts WHERE filler LIKE '%x%';
144144 The query writes any data or locks any database rows. If a query
145145 contains a data-modifying operation either at the top level or within
146146 a CTE, no parallel plans for that query will be generated. As an
147- exception, the following commands which create a new table and populate
148- it can use a parallel plan for the underlying <literal>SELECT</literal>
147+ exception, the following commands, which create a new table and populate
148+ it, can use a parallel plan for the underlying <literal>SELECT</literal>
149149 part of the query:
150150
151151 <itemizedlist>
@@ -255,7 +255,7 @@ EXPLAIN SELECT * FROM pgbench_accounts WHERE filler LIKE '%x%';
255255 than normal but would produce incorrect results. Instead, the parallel
256256 portion of the plan must be what is known internally to the query
257257 optimizer as a <firstterm>partial plan</firstterm>; that is, it must be constructed
258- so that each process which executes the plan will generate only a
258+ so that each process that executes the plan will generate only a
259259 subset of the output rows in such a way that each required output row
260260 is guaranteed to be generated by exactly one of the cooperating processes.
261261 Generally, this means that the scan on the driving table of the query
@@ -365,11 +365,11 @@ EXPLAIN SELECT * FROM pgbench_accounts WHERE filler LIKE '%x%';
365365
366366 <para>
367367 Because the <literal>Finalize Aggregate</literal> node runs on the leader
368- process, queries which produce a relatively large number of groups in
368+ process, queries that produce a relatively large number of groups in
369369 comparison to the number of input rows will appear less favorable to the
370370 query planner. For example, in the worst-case scenario the number of
371371 groups seen by the <literal>Finalize Aggregate</literal> node could be as many as
372- the number of input rows which were seen by all worker processes in the
372+ the number of input rows that were seen by all worker processes in the
373373 <literal>Partial Aggregate</literal> stage. For such cases, there is clearly
374374 going to be no performance benefit to using parallel aggregation. The
375375 query planner takes this into account during the planning process and is
@@ -425,7 +425,7 @@ EXPLAIN SELECT * FROM pgbench_accounts WHERE filler LIKE '%x%';
425425 involve appending multiple results sets can therefore achieve
426426 coarse-grained parallelism even when efficient partial plans are not
427427 available. For example, consider a query against a partitioned table
428- which can only be implemented efficiently by using an index that does
428+ that can only be implemented efficiently by using an index that does
429429 not support parallel scans. The planner might choose a <literal>Parallel
430430 Append</literal> of regular <literal>Index Scan</literal> plans; each
431431 individual index scan would have to be executed to completion by a single
@@ -446,7 +446,7 @@ EXPLAIN SELECT * FROM pgbench_accounts WHERE filler LIKE '%x%';
446446 If a query that is expected to do so does not produce a parallel plan,
447447 you can try reducing <xref linkend="guc-parallel-setup-cost"/> or
448448 <xref linkend="guc-parallel-tuple-cost"/>. Of course, this plan may turn
449- out to be slower than the serial plan which the planner preferred, but
449+ out to be slower than the serial plan that the planner preferred, but
450450 this will not always be the case. If you don't get a parallel
451451 plan even with very small values of these settings (e.g., after setting
452452 them both to zero), there may be some reason why the query planner is
@@ -473,15 +473,15 @@ EXPLAIN SELECT * FROM pgbench_accounts WHERE filler LIKE '%x%';
473473 <para>
474474 The planner classifies operations involved in a query as either
475475 <firstterm>parallel safe</firstterm>, <firstterm>parallel restricted</firstterm>,
476- or <firstterm>parallel unsafe</firstterm>. A parallel safe operation is one which
476+ or <firstterm>parallel unsafe</firstterm>. A parallel safe operation is one that
477477 does not conflict with the use of parallel query. A parallel restricted
478- operation is one which cannot be performed in a parallel worker, but which
478+ operation is one that cannot be performed in a parallel worker, but that
479479 can be performed in the leader while parallel query is in use. Therefore,
480480 parallel restricted operations can never occur below a <literal>Gather</literal>
481- or <literal>Gather Merge</literal> node, but can occur elsewhere in a plan which
482- contains such a node. A parallel unsafe operation is one which cannot
481+ or <literal>Gather Merge</literal> node, but can occur elsewhere in a plan that
482+ contains such a node. A parallel unsafe operation is one that cannot
483483 be performed while parallel query is in use, not even in the leader.
484- When a query contains anything which is parallel unsafe, parallel query
484+ When a query contains anything that is parallel unsafe, parallel query
485485 is completely disabled for that query.
486486 </para>
487487
@@ -505,7 +505,7 @@ EXPLAIN SELECT * FROM pgbench_accounts WHERE filler LIKE '%x%';
505505 <listitem>
506506 <para>
507507 Scans of foreign tables, unless the foreign data wrapper has
508- an <literal>IsForeignScanParallelSafe</literal> API which indicates otherwise.
508+ an <literal>IsForeignScanParallelSafe</literal> API that indicates otherwise.
509509 </para>
510510 </listitem>
511511
@@ -517,7 +517,7 @@ EXPLAIN SELECT * FROM pgbench_accounts WHERE filler LIKE '%x%';
517517
518518 <listitem>
519519 <para>
520- Plan nodes which reference a correlated <literal>SubPlan</literal>.
520+ Plan nodes that reference a correlated <literal>SubPlan</literal>.
521521 </para>
522522 </listitem>
523523 </itemizedlist>
@@ -528,7 +528,7 @@ EXPLAIN SELECT * FROM pgbench_accounts WHERE filler LIKE '%x%';
528528 <para>
529529 The planner cannot automatically determine whether a user-defined
530530 function or aggregate is parallel safe, parallel restricted, or parallel
531- unsafe, because this would require predicting every operation which the
531+ unsafe, because this would require predicting every operation that the
532532 function could possibly perform. In general, this is equivalent to the
533533 Halting Problem and therefore impossible. Even for simple functions
534534 where it could conceivably be done, we do not try, since this would be expensive
@@ -546,11 +546,11 @@ EXPLAIN SELECT * FROM pgbench_accounts WHERE filler LIKE '%x%';
546546 <para>
547547 Functions and aggregates must be marked <literal>PARALLEL UNSAFE</literal> if
548548 they write to the database, access sequences, change the transaction state
549- even temporarily (e.g., a PL/pgSQL function which establishes an
549+ even temporarily (e.g., a PL/pgSQL function that establishes an
550550 <literal>EXCEPTION</literal> block to catch errors), or make persistent changes to
551551 settings. Similarly, functions must be marked <literal>PARALLEL
552552 RESTRICTED</literal> if they access temporary tables, client connection state,
553- cursors, prepared statements, or miscellaneous backend-local state which
553+ cursors, prepared statements, or miscellaneous backend-local state that
554554 the system cannot synchronize across workers. For example,
555555 <literal>setseed</literal> and <literal>random</literal> are parallel restricted for
556556 this last reason.
@@ -568,10 +568,10 @@ EXPLAIN SELECT * FROM pgbench_accounts WHERE filler LIKE '%x%';
568568 </para>
569569
570570 <para>
571- If a function executed within a parallel worker acquires locks which are
571+ If a function executed within a parallel worker acquires locks that are
572572 not held by the leader, for example by querying a table not referenced in
573573 the query, those locks will be released at worker exit, not end of
574- transaction. If you write a function which does this, and this behavior
574+ transaction. If you write a function that does this, and this behavior
575575 difference is important to you, mark such functions as
576576 <literal>PARALLEL RESTRICTED</literal>
577577 to ensure that they execute only in the leader.
0 commit comments