- 论坛徽章:
- 0
|
1。select v.* from video v,video_tag vt,tag t
where t.tag_id=vt.tag_id and v.video_id=vt.video_id
and t.name like '%test%' and v.video_state='4' and v.audit_flag='1';
1 | SIMPLE | v | ref | PRIMARY,indx_video | indx_video | 9 | const,const | 36055 | Using where |
| 1 | SIMPLE | vt | ref | unique_vtag,index_tag_id | unique_vtag | 4 | videoCommunity.v.video_id | 1 | Using index |
| 1 | SIMPLE | t | eq_ref | PRIMARY | PRIMARY | 4 | videoCommunity.vt.tag_id | 1 | Using where |
一般来说执行2秒
2。select v.* from video v join
(select vt.* from video_tag vt ,tag t where t.tag_id=vt.tag_id and t.name like '%test%' )
tt on v.video_state='4' and v.audit_flag='1' and v.video_id=tt.video_id
1 | PRIMARY | <derived2> | ALL | NULL | NULL | NULL | NULL | 53 | |
| 1 | PRIMARY | v | eq_ref | PRIMARY,indx_video | PRIMARY | 4 | tt.video_id | 1 | Using where |
| 2 | DERIVED | t | index | PRIMARY | unique_tag | 767 | NULL | 31109 | Using where; Using index |
| 2 | DERIVED | vt | ref | index_tag_id | index_tag_id | 4 | videoCommunity.t.tag_id | 2 |
一般只要0.05秒
但是从explain中看不出到底差在哪里?
但是事实确实要快。 不知道各位有什么看法! |
|