164 Star 224 Fork 1.2K

openGauss / docs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
Join方式的Hint.md 1.56 KB
一键复制 编辑 原始数据 按行查看 历史

Join方式的Hint

功能描述

指明Join使用的方法,可以为Nested Loop,Hash Join和Merge Join。

语法格式

[no] nestloop|hashjoin|mergejoin(table_list)

参数说明

  • no表示hint的join方式不使用。

  • table_list为表示hint表集合的字符串,该字符串中的表与join_table_list相同,只是中间不允许出现括号指定join的优先级。

例如:

no nestloop(t1 t2 t3)表示:生成t1,t2,t3三表连接计划时,不使用nestloop。三表连接计划可能是t2 t3先join,再跟t1 join,或t1 t2先join,再跟t3 join。此hint只hint最后一次join的join方式,对于两表连接的方法不hint。如果需要,可以单独指定,例如:任意表均不允许nestloop连接,且希望t2 t3先join,则增加hint:no nestloop(t2 t3)。

示例

示例中原语句使用如下hint:

explain
select /*+ nestloop(store_sales store_returns item) */ i_product_name product_name ...

该hint表示:生成store_sales,store_returns和item三表的结果集时,最后的两表关联使用nestloop。生成计划如下所示:

1
https://gitee.com/opengauss/docs.git
git@gitee.com:opengauss/docs.git
opengauss
docs
docs
1.0.1

搜索帮助