如何优化连接查询... ?? [英] how to optimize the join query...??

查看:87
本文介绍了如何优化连接查询... ??的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



i需要优化连接查询,连接三个表

说table1,table2,table3每个都有大量的记录......

查询为

hi
i need to optimize the join query, which joins three tables
say table1 ,table2 , table3 each having huge volume of records...
the query is as

展开 | 选择 | Wrap | 行号

推荐答案

Heya,Bravo。


你的经历非常普遍;大型数据集的连接速度很慢。


在这种情况下,通过将其分解为三个单独的查询或使用子查询,您将获得更好的服务。


您可以尝试进行外连接;有时可行:
Heya, Bravo.

Your experience is quite common; joins are SLOW for large datasets.

You''d be better served in this case by either breaking it up into three separate queries, or by using subqueries.

You could try doing outer joins; sometimes that works:
展开 | 选择 < span class =codeDivider> | Wrap | 行号


谢谢

根据您的建议我尝试过subquerries但遗憾的是仍然由于某些原因,我无法将其分解为不同的查询...

i需要结果集如

Table1

id |姓名

1 | a

2 | b

3 | c


表2

id |时间

2 | 0:0

3 | 0:1


表3

id |状态

3 |真的


我需要结果集为

id |时间|状态

1 | null | null

2 | 0:0 | null

3 | 0:1 |真的


但是没有通过子查询得到它,使用连接获得正确的设置但是对于巨大的设置效率不高

plz帮助我....我被困了
Thanks
as per ur suggestions i tried subquerries but unfortunately still not getting any
fruitfull result.i cant break it into different queries due to some reasons...
i need the result set like
Table1
id | name
1 | a
2 | b
3 | c


Table2
id | time
2 | 0:0
3 | 0:1

Table 3
id | status
3 | true

I need the result set as
id | time | status
1 | null | null
2 | 0:0 | null
3 | 0:1 | true

but not getting it right through subqueries, getting right set using join but it is not efficient for huge set
plz help me out.... i am stuck


Heya,bravo。


如果你运行这个查询你会得到什么:
Heya, bravo.

What do you get if you run this query:
展开 | 选择 | Wrap | 行号


这篇关于如何优化连接查询... ??的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆