Oracle数据库:
刚做一张5000万条数据的数据抽取,当前表同时还在继续insert操作,每分钟几百条数据。
该表按照时间,以月份为单位做的表分区,没有任何索引,当前共有14个字段,平均每个字段30个字节。当前表分区从201101到201512每月一个分区
测试服务器:xeno 5650,32核cpu,win2003操作系统,物理内存16G;测试工具plsql
1.最开始的查询:
string.Format(@"select * from
(select r.id,r.carcode,r.longtitude,r.latitude,r.velocity,r.gpstime,r.isonline from t_gps_record r where id in(
select min(id) from t_gps_record r where carcode='{0}'
group by to_char(gpstime,'yyyy-MM-dd HH24:mi'))
and carcode='{0}'
and gpstime>(select nvl((select max(gpstime) from t_gps_carposition where carcode='{0}'),(select min(gpstime) from t_gps_record where carcode='{0}')) from dual)
order by gpstime asc
) where rownumto_date('2011-11-1 00:00:00','yyyy-mm-dd HH24:mi:ss')
order by gpstime asc
) where rownum