GBase 8s
性能调优
文章
表的关联查询,哪种写法效率更高?
GBase社区管理员发表于2023-05-11 15:31:2170次浏览0个评论
方法1:嵌套子查询
select col1,col2
from tab1
where id in (select 2_id
from tab2
where order_num in ( select order_num
from tab3
where prod_id='AAA'))
方法2:无嵌套子查询
select col1,col2
from tab1,tab2,tab3
where
tab1.id=tab2.id
and tab2.order_num =tab3.order_num
and tab3.prod_id='AAA'方法3:INNER JOIN
select col1,col2
from tab1
inner join tab2 on tab1.id=tab2.id
inner join tab3 on tab2.order_num =tab3.order_num
where
prod_id='AAA'我估计不同的数据库的优化器,性能应该是有千差万别的。
请各位在不同的数据库上进行测试,并帮忙反馈一下测试结果哟
评论已关闭
热门帖子
- 12025-12-01浏览数:182759
- 22023-05-09浏览数:25044
- 42023-09-25浏览数:18519
- 52020-05-11浏览数:17526