首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

请问多表查询效率有关问题

2012-03-17 
请教多表查询效率问题!请问大侠们,多表查询时,以下两种方式哪种效率高些,原因何在?多谢指教!1、selecta.t1,

请教多表查询效率问题!
请问大侠们,多表查询时,以下两种方式哪种效率高些,原因何在?多谢指教!
1、select   a.t1,a.t2,b.t3,b.t4,c.t5,c.t6
from   biao1   a,biao2   b,biao3   c
where   a.id=b.id   and   a.id=c.id   and   a.rq= '2007-01-01 '
2、select   a.t1,a.t2,b.t3,b.t4,c.t5,c.t6
from   biao1   a   join   biao2   b   on   a.id=b.id
join   biao3   c   on   a.id=c.id
where   a.rq= '2007-01-01 '


[解决办法]
方法是
在select语句前使用
declare @d datetime

set @d=getdate()

并在select语句后加:

select [语句执行花费时间(毫秒)]=datediff(ms,@d,getdate())
[解决办法]
第一种没有指明联结方式,有可能产生迪卡尔集,浪费了时间。

热点排行