select TO_CHAR(V_TIME,'YYYY-MM-DD')
count(*),count(distinct ip),count(distinct c_id) from a
where V_TIME between ··and···
group by TO_CHAR(V_TIME,'YYYY-MM-DD');
十万级的现在是10s多,有人帮忙,看看如何优化吗~~~~
count(*),count(distinct ip),count(distinct c_id) from a
where V_TIME between ··and···
group by TO_CHAR(V_TIME,'YYYY-MM-DD');
十万级的现在是10s多,有人帮忙,看看如何优化吗~~~~
2、优化sql
select trunc(V_TIME),
count(*),count(distinct ip),count(distinct c_id) from a
where V_TIME between ··and···
group by trunc(V_TIME);
1,是不是你查询的数据量太多了,占据了总量的20%以上呢,这样的话,就只能走表扫描了,table span。2,另外你的group by的时间字段最要好把to_char函数改成trunc函数,而且针对trunc()函数执行的结果建索引试试看。