15.2. 啓用時機?
- max_parallel_workers_per_gathermust be set to a value which is greater than zero. This is a special case of the more general principle that no more workers should be used than the number configured via.
- must be set to a value other than
none
. Parallel query requires dynamic shared memory in order to pass data between cooperating processes.
- The query writes any data or locks any database rows. If a query contains a data-modifying operation either at the top level or within a CTE, no parallel plans for that query will be generated. This is a limitation of the current implementation which could be lifted in a future release.
- The query uses any function marked. Most system-defined functions are
PARALLEL SAFE
, but user-defined functions are markedPARALLEL UNSAFE
by default. See the discussion ofSection 15.4. - The query is running inside of another query that is already parallel. For example, if a function called by a parallel query issues an SQL query itself, that query will never use a parallel plan. This is a limitation of the current implementation, but it may not be desirable to remove this limitation, since it could result in a single query using a very large number of processes.
- The transaction isolation level is serializable. This is a limitation of the current implementation.
- No background workers can be obtained because of the limitation that the total number of background workers launched for purposes of parallel query cannot exceed.
- The client sends an Execute message with a non-zero fetch count. See the discussion of theextended query protocol. Sincecurrently provides no way to send such a message, this can only occur when using a client that does not rely on libpq. If this is a frequent occurrence, it may be a good idea to setmax_parallel_workers_per_gatherin sessions where it is likely, so as to avoid generating query plans that may be suboptimal when run serially.
- A prepared statement is executed using a
CREATE TABLE .. AS EXECUTE ..
statement. This construct converts what otherwise would have been a read-only operation into a read-write operation, making it ineligible for parallel query.