现有YC对CNTR进行操作,每进行一次操作就会在表cntr_event记录,里面有yc_m,cntr_n,event_dt三个字段,分别代表YC的名字CNTR的名字以及操作的时间(精确到秒 not null).
现在要求统计一个月中每天某个时段如2:00 -- 3:40, 11:00 -- 12:30, 18:00 -- 19:30每个YC的操作数,该如何执行性能会好些.
注:表里面数据量比较打,大概在2百万条记录左右
我现在能想出来的方案是按时段分三次取库,如:
select yc_m, count(*) as moves, trunc(event_dt, 'dd') as event_d
from cntr_event 
where to_number(to_char(event_dt, 'hh24miss')) >= 020000 and
      to_number(to_char(event_dt, 'hh24miss')) < 033000 and
      event_dt >= to_date('2007-01-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss') and 
      event_dt < to_date('2007-02-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss')
group by yc_m, trunc(event_dt, 'dd')我的问题是:想请教各位大大,有没有比较好的解决方案,还有用上面的sql的话有没有什么安全上的隐患及性能问题.
谢谢!