Hints for Specifying the Degree of Parallelism for Scans
Description
The degree of parallelism (DOP) is specified for table scans in a parallel execution plan.
Syntax
scandop([@queryblock] table dop_num)
Parameters
- For details about @queryblock, see Hint Specifying the Query Block Where the Hint Is Located. @queryblock can be omitted, indicating that the hint takes effect in the current query block.
- table specifies the table to be scanned. You can specify only one table. Use a table alias (if any) instead of a table name.
- dop_num specifies the DOP for table scans.
- scandop specifies a hint for specifying the DOP for scans.
Examples
-- Preparation
CREATE TABLE cst1(a int, b int, c int, d bigint);
set explain_perf_mode = pretty; -- Open the explain pretty option to view a detailed plan.
set enable_fast_query_shipping = off; -- Disable FQS optimization.
-- Usage
gaussdb=# EXPLAIN (costs off) SELECT /*+ Set(query_dop 2) scandop(cst1 2)*/ * FROM cst1;
id | operation
----+-----------------------------------------------
1 | -> Streaming (type: GATHER)
2 | -> Streaming(type: LOCAL GATHER dop: 1/2)
3 | -> Seq Scan on cst1
(3 rows)
In a parallel plan, you can use scandop hints to specify the degree of parallelism.

The hint takes effect only when dop_num is the same as the current degree of parallelism (query_dop) or is set to 1.
gaussdb=# EXPLAIN (costs off) SELECT /*+ Set(query_dop 2) scandop(cst1 4)*/ * FROM cst1;
id | operation
----+----------------------
1 | -> Seq Scan on cst1
(1 row)
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.