
# 指定扫描并行度的Hint
#### 功能描述
在并行的执行计划中，指定表扫描的并行度。
#### 语法格式
```
scandop([@queryblock] table dop_num)
```
#### 参数说明
- @queryblock请参见[指定Hint所处的查询块Queryblock](https://support.huaweicloud.com/distributed-devg-v8-gaussdb/gaussdb-12-0273.html#ZH-CN_TOPIC_0000002559105637)，可省略，表示在当前查询块生效。
- table表示hint指定的表，只能指定一个表，如果表存在别名，应优先使用别名进行hint。
- dop_num表示使用表扫描的并行度。
- scandop指定扫描并行度的hint。
 
#### 示例
```
--准备
CREATE TABLE cst1(a int, b int, c int, d bigint);
set explain_perf_mode = pretty;  --打开explain pretty选项，可以看到更详尽计划
set enable_fast_query_shipping = off;  --关闭fqs优化
--使用
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)
```
可以在并行计划中，使用scandop hint可以成功指定扫描并行度。
![](https://support.huaweicloud.com/distributed-devg-v8-gaussdb/public_sys-resources/note_3.0-zh-cn.png)
只有当dop_num和当前并行度（query_dop）一致或为1时，hint才会生效。
```
gaussdb=# EXPLAIN (costs off) SELECT /*+ Set(query_dop 2) scandop(cst1 4)*/ * FROM cst1;
 id |      operation       
----+----------------------
  1 | ->  Seq Scan on cst1
(1 row)
```
