select distinct domain,sum(total) from
(
select distinct domain,sum(if(record_status=0,1,0)) total from t_prehandle_zhigao_01 where record_status = 0 group by domain
union all
select distinct domain,sum(if(record_status=0,1,0)) total from t_prehandle_zhigao_02 where record_status = 0 group by domain
union all
select distinct domain,sum(if(record_status=0,1,0)) total from t_prehandle_zhigao_03 where record_status = 0 group by domain
union all
select distinct domain,sum(if(record_status=0,1,0)) total from t_prehandle_zhigao_04 where record_status = 0 group by domain
union all
select distinct domain,sum(if(record_status=0,1,0)) total from t_prehandle_zhigao_05 where record_status = 0 group by domain
) t1
group by domain;
九百万行数据,执行上述语句需要1分钟多一点,请问是否正常,能否更快
(
select distinct domain,sum(if(record_status=0,1,0)) total from t_prehandle_zhigao_01 where record_status = 0 group by domain
union all
select distinct domain,sum(if(record_status=0,1,0)) total from t_prehandle_zhigao_02 where record_status = 0 group by domain
union all
select distinct domain,sum(if(record_status=0,1,0)) total from t_prehandle_zhigao_03 where record_status = 0 group by domain
union all
select distinct domain,sum(if(record_status=0,1,0)) total from t_prehandle_zhigao_04 where record_status = 0 group by domain
union all
select distinct domain,sum(if(record_status=0,1,0)) total from t_prehandle_zhigao_05 where record_status = 0 group by domain
) t1
group by domain;
九百万行数据,执行上述语句需要1分钟多一点,请问是否正常,能否更快
from (
select domain,count(*) as total from t_prehandle_zhigao_01 where record_status=0 group by domain
union all
select domain,count(*) as total from t_prehandle_zhigao_02 where record_status=0 group by domain
union all
select domain,count(*) as total from t_prehandle_zhigao_03 where record_status=0 group by domain
union all
select domain,count(*) as total from t_prehandle_zhigao_04 where record_status=0 group by domain
union all
select domain,count(*) as total from t_prehandle_zhigao_05 where record_status=0 group by domain
) as t1
group by domain同样的结果,应该会快一些。
[align=center]==== 思想重于技巧 ====
[/align]
[align=center]==== 思想重于技巧 ====
[/align]
[align=center]==== 思想重于技巧 ====
[/align]
另外貌似COUNT(*)没有sum(if(record_status=0,1,0))这个快
问题是一朋友问的,我帮他写的语句,没有接触过这么大的表,不知道这个运算时间是否正常,故此一问
[align=center]==== 思想重于技巧 ====
[/align]
有处理过这么大的表的吗?1分钟可以接受吗?
比较快。
[align=center]==== 思想重于技巧 ====
[/align]