![]() |
|
首页 │ Apache │ Linux│ Java│ MySQL│ 注册│帮助 | |||
相关问题
下面的两句查询语句,出来结果是一样的,为什么内联接查询的速度会快些呢?
$s1="select a.*,b.num from table1 as a inner join (select id,count(*)as num from table2 where u>1 group by id) as a on a.id=b.id";
$s2=select a.*,b.num from table1 as a ,(select id,count(*)as num from table2 where u>1 group by id) as b where a.id=b.id"";
下面是对几百条数据进行查询的测试
这是执行s语句的查询时间
0.040399074554443
0.029947996139526
0.16188192367554
0.033388137817383
0.037020921707153
这是执行s2语句的查询时间
0.031352996826172
0.24414396286011
0.026689052581787
0.13314700126648
0.43685793876648
经过几组测试都是s1的相对时间要少.为什么呢!
[ 本帖最后由 gh520 于 2006-5-14 11:43 PM 编辑 ]
提问者:gh520 08-21 17:05
答复

