如何在内连接中快速查询 [英] how to make query fast in inner join

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

问题描述

我有两个表管理器(id,name)和emp(id,name,managerid)。

所有员工都有自己的经理ID。

如果有1个lac记录在emp表中为经理ID 2

哪个查询会给出快速结果



I have two table Manager(id,name) and emp(id,name ,managerid).
All employee has own manager id.
If 1 lac record in emp table for manager id 2
Which query will give fast result

select * from emp e
inner join Manager m on m.id=e.managerid
where e.managerid=2











or

select * from emp e
inner join Manager m on m.id=e.managerid
where m.id=2

推荐答案

如果两个managerid和id列是索引,这不会有任何区别。

然而,有什么可能有所作为,避免选择*,并只选择你需要的实际列。
If both managerid and id columns are indexed, that won't make any difference.
What could make a difference, though, is avoiding select *, and select only the actual columns you need.


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

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