56,677
社区成员
发帖
与我相关
我的任务
分享
explain select xm,sj,dzyj,byear,bmonth,zgxl,zgxlzy,date from peopledata as p,peopqz as z where p.userid=z.userid and z.gw like '%销售%' and left(z.datetime,10)>='2009-01-01' and left(z.datetime,10)<='2009-04-01' limit 10;
| id | select_type | table | type | possible_keys | key | key_len | ref | rows
| Extra |
+----+-------------+-------+------+---------------+------+---------+------+-----
--+--------------------------------+
| 1 | SIMPLE | z | ALL | NULL | NULL | NULL | NULL | 959
6 | Using where |
| 1 | SIMPLE | p | ALL | NULL | NULL | NULL | NULL | 7463
4 | Using where; Using join buffer |
+----+-------------+-------+------+---------------+------+---------+------+-----
explain select a.*
from (select xm,sj,dzyj,byear,bmonth,zgxl,zgxlzy,date,userid from peopledata where date>='2009-01-01' and date <='2009-04-01') a ,peopqz b
where a.userid=b.userid
and b.gw like '%销售%' limit 10;
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+------------+------+---------------+------+---------+------+
-------+--------------------------------+
| 1 | PRIMARY | <derived2> | ALL | NULL | NULL | NULL | NULL | 8314 | |
| 1 | PRIMARY | b | ALL | NULL | NULL | NULL | NULL | 9596 | Using where; Using join buffer |
| 2 | DERIVED | peopledata | ALL | NULL | NULL | NULL | NULL | 74634 | Using where |
+----+-------------+------------+------+---------------+------+---------+------+
select a.*
from (select xm,sj,dzyj,byear,bmonth,zgxl,zgxlzy,date,userid from peopledata where date>='2009-01-01' and date <='2009-04-01') a ,peopqz b
where a.userid=b.userid
and b.gw like '%销售%' limit 10;
select a.*
from (select xm,sj,dzyj,byear,bmonth,zgxl,zgxlzy,date,userid from peopledata where date>='2009-01-01' and date <='2009-04-01') a inner join peopqz b on a.userid=b.userid
where b.gw like '%销售%' limit 10;
select a.*
from (
select xm,xb,xl,age
from table1
where date>='2009-01-01' and date <='2009-02-01'
) a inner join table2 b where a.id=b.id