Parallelism hints v15
Parallel scanning is the use of multiple background workers to simultaneously perform a scan of a table, that is, in parallel, for a given query. This process provides performance improvement over other methods such as the sequential scan.
- The
PARALLEL
optimizer hint forces parallel scanning. - The
NO_PARALLEL
optimizer hint prevents use of a parallel scan.
Synopsis
Parameters
table
The table to which to apply the parallel hint.
parallel_degree | DEFAULT
parallel_degree
is a positive integer that specifies the desired number of workers to use for a parallel scan. If specified, the lesser of parallel_degree
and configuration parameter max_parallel_workers_per_gather
is used as the planned number of workers. For information on the max_parallel_workers_per_gather
parameter, see Asynchronous Behavior under Resource Consumption in the PostgreSQL core documentation.
If you specify
DEFAULT
, then the maximum possible parallel degree is used.If you omit both
parallel_degree
andDEFAULT
, then the query optimizer determines the parallel degree. In this case, iftable
was set with theparallel_workers
storage parameter, then this value is used as the parallel degree. Otherwise, the optimizer uses the maximum possible parallel degree as ifDEFAULT
were specified. For information on theparallel_workers
storage parameter, seeStorage Parameters
underCREATE TABLE
in the PostgreSQL core documentation.Regardless of the circumstance, the parallel degree never exceeds the setting of configuration parameter
max_parallel_workers_per_gather
.
About the examples
For these exammples, the following configuration parameter settings are in effect:
Example: Default scan
This example shows the default scan on table pgbench_accounts
. A sequential scan is shown in the query plan.