select a.sick_order,b.cancel_order,c.refuse_order from
(select count(log) sick_order from log where source ='tb'and log like '%2016-04-29%' and log like '%update%') a,
(select count(log) cancel_order from log where source ='tb'and log like '%2016-04-29%' and log like '%cancel%') b,
(select count(*) refuse_order from webapp_log_detail where website_id='tb000' and arr_time like '2016-04-29%' and (buss2 is null or buss2 = '')) c
这条语句执行时间太长,怎么优化一下,缩短时间?
(select count(log) sick_order from log where source ='tb'and log like '%2016-04-29%' and log like '%update%') a,
(select count(log) cancel_order from log where source ='tb'and log like '%2016-04-29%' and log like '%cancel%') b,
(select count(*) refuse_order from webapp_log_detail where website_id='tb000' and arr_time like '2016-04-29%' and (buss2 is null or buss2 = '')) c
这条语句执行时间太长,怎么优化一下,缩短时间?
你这样肯定是会慢的,log表数据量本来就很大,你还 like %xxx%,就算有索引也用不上。如果实在不行,建议先做一个结存表,结存某个日期中,update,insert,等操作时,分别的数据都结存到一个表里