使用内部连接需要很长时间的Sql查询 [英] Sql query taking long time with inner join

查看:35
本文介绍了使用内部连接需要很长时间的Sql查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该编写一个需要连接 3 个表的查询.我设计的查询效果很好,但是执行起来需要很多时间.

I am supposed to write a query which requires joining 3 tables. The query designed by me works fine, but it takes a lot of time to execute.

SELECT v.LinkID,  r.SourcePort, r.DestPort, r.NoOfBytes, r.StartTime , r.EndTime, r.Direction, r.nFlows
FROM LINK_TBL v 
INNER JOIN NODEIF_TBL n 
INNER JOIN RAW_TBL r ON 
    r.RouterIP=n.ifipaddress 
    and n.NodeNumber=v.orinodenumber 
    and v.oriIfIndex=r.OriIfIndex;

此查询中的性能是否存在任何问题?

Is there any issue w.r.t performance in this query ?

推荐答案

试试这个把 on 条件放在 joins 中

Try this one put the on conditions in the joins

SELECT v.LinkID,  r.SourcePort, r.DestPort, r.NoOfBytes, r.StartTime , r.EndTime, r.Direction, r.nFlows
FROM LINK_TBL v 
INNER JOIN NODEIF_TBL n ON (n.NodeNumber=v.orinodenumber )
INNER JOIN RAW_TBL r ON (r.RouterIP=n.ifipaddress   and v.oriIfIndex=r.OriIfIndex)

这篇关于使用内部连接需要很长时间的Sql查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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