数据库表:GPS_LOG,索引为车牌号
特点 :同一辆车会用N条不用时间段上传的GPS数据
查询目标:从GPS_LOG表获取某一时间段上传过GPS的数据的车辆车牌号码,相同车牌号只去一条。
方法:Select distinct t.plateno from GPS_LOG t Where t.indate between P_StartTime and P_EndTime;
执行时间需要几十分钟。原因:加了distinct后索引无效。
对比:Select t.plateno from GPS_LOG t Where t.indate between P_StartTime and P_EndTime;
执行结果小于10S,但结果集不是查询要求,车牌号重复。
求助:如题?
特点 :同一辆车会用N条不用时间段上传的GPS数据
查询目标:从GPS_LOG表获取某一时间段上传过GPS的数据的车辆车牌号码,相同车牌号只去一条。
方法:Select distinct t.plateno from GPS_LOG t Where t.indate between P_StartTime and P_EndTime;
执行时间需要几十分钟。原因:加了distinct后索引无效。
对比:Select t.plateno from GPS_LOG t Where t.indate between P_StartTime and P_EndTime;
执行结果小于10S,但结果集不是查询要求,车牌号重复。
求助:如题?
解决方案 »
- 问一个JOB问题,为什么thisdate比nextdate还晚?
- 如何把来自64bit的Oracle的dmp文件导入到32bit的Oracle里面
- DESC和User_Tab_Cols查询的结果不一样,求助
- virtualbox中无法分区
- declare,if简单常识求教
- ORCALE 内在那里看到表?我只 用过sqlserver 请问 我想看某个表内的数据 要如何操作 ?
- 通过ODBC,如何往Oracle数据库中插入一个包含附件的记录?
- 删除了回滚段rb7,数据库只能startup 到mount状态,怎么办?
- Oracle 设置问题
- scott用户下建了DDL触发器,无法删除怎么办?
- 表中的记录删除后重新插入,rowid有没有可能和以前的有冲突?
- 如何写触发器自增数据
(Select plateno from GPS_LOG Where indate between P_StartTime and P_EndTime) q;
and exists(select 1 form gps_log a where t.plateno=a.plateno and p.rowid<a.rowid)
方法一:
Select t.plateno from Gps_Log_Hazmat t
Where t.indate>sysdate-0.01
and exists(select a.plateno from gps_log_hazmat a
where t.plateno=a.plateno and t.rowid <a.rowid);Select t.plateno from Vehcile_Hazmat t ---注表Vehcile_Hazmat是车辆基础信息表,车牌号唯一
Where exists(select a.plateno from gps_log_hazmat a
where t.plateno=a.plateno and t.rowid <a.rowid);
执行效果一样没有提高,还是几十分钟。
Select t.plateno from Gps_Log_Hazmat t
Where Where t.indate between P_StartTime and P_EndTime
and exists(select a.plateno from gps_log_hazmat a
where t.plateno=a.plateno and t.rowid <a.rowid);
方法二:
Select t.plateno from Vehcile_Hazmat t ---注表Vehcile_Hazmat是车辆基础信息表,车牌号唯一
Where exists(select a.plateno from gps_log_hazmat a
where t.plateno=a.plateno
and a.indate between P_StartTime and P_EndTime);
执行效果一样没有提高,还是几十分钟。
group by t.plateno
Select t.plateno from GPS_LOG t Where t.indate between P_StartTime and P_EndTime
group by t.plateno
的sql语句有问题,执行肯定不通过,
group by t.plateno 没有distinct的功能
方法:给GPS_LOG表按日期分区存储数据,这样保证每各分区的数据量大概在2千万条。然后给INDATAE列建索引。
执行效率小于8S