
# Scan方式的Hint
#### 功能描述
指明scan使用的方法，可以是tablescan、indexscan和indexonlyscan。
#### 语法格式
```
[no] tablescan|indexscan|indexonlyscan(table [index])
```
#### 参数说明
- **no**表示hint的scan方式不使用。
 
- **table**表示hint指定的表，只能指定一个表，如果表存在别名应优先使用别名进行hint。
- **index**表示使用indexscan或indexonlyscan的hint时，指定的索引名称，当前只能指定一个。
![](https://support.huaweicloud.com/distributed-devg-v2-gaussdb/public_sys-resources/note_3.0-zh-cn.png)
对于indexscan或indexonlyscan，只有hint的索引属于hint的表时，才能使用该hint。
scan hint支持在行存表、子查询表上指定。
#### 示例
为了hint使用索引扫描，需要首先在表item的i_item_sk列上创建索引，名称为i。
```
create index i on item(i_item_sk);
```
对[示例](https://support.huaweicloud.com/distributed-devg-v2-gaussdb/gaussdb-12-0194.html#ZH-CN_TOPIC_0000002187368496__zh-cn_topic_0000002220898557_section671421102912)中原语句使用如下hint:
```
explain
select /*+ indexscan(item i) */ i_product_name product_name ...
```
该hint表示：item表使用索引i进行扫描。生成计划如下所示：
![](https://support.huaweicloud.com/distributed-devg-v2-gaussdb/figure/zh-cn_image_0000002185618502.png "点击放大")
