亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

Oracle大數據量查詢實際分析

系統 1885 0

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 rownum<=200 ", row["carcode"].ToString());

一開始以200條數據為段進行查詢,查詢一次2分鐘16秒;

后來查20條,2分鐘14秒;基本跟條數無關。


2.后來把最小時間寫成固定的:

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>to_date('2011-11-1 00:00:00','yyyy-mm-dd HH24:mi:ss')
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? order by gpstime asc?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ) where rownum<=200 ", row["carcode"].ToString());

查詢時間 1分34秒。


3.不加分區查詢

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
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? group by carcode, to_char(gpstime,'yyyy-MM-dd HH24:mi'))?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? and gpstime>=to_date('2011-11-1 9:00:00','yyyy-mm-dd HH24:mi:ss') and gpstime<=to_date('2011-11-1 9:59:59','yyyy-mm-dd HH24:mi:ss')
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? order by gpstime asc?

查詢時間:3分29秒,共1426條


4.添加分區查詢

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 partition(GPSHISTORY201111) r ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? group by carcode, to_char(gpstime,'yyyy-MM-dd HH24:mi')) ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? and gpstime>=to_date('2011-11-1 9:00:00','yyyy-mm-dd HH24:mi:ss') and gpstime<=to_date('2011-11-1 9:59:59','yyyy-mm-dd HH24:mi:ss')
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? order by gpstime asc?


添加分區后查詢:17s,共1426條


所以加分區后的查詢效率提高十幾倍,所以大數據量建立分區表是相當重要的。




?

Oracle大數據量查詢實際分析


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 在线观看亚洲网站 | 免费看成人频视在线视频 | 婷婷中文在线 | 免费观看一级毛片 | 久久精品一区二区三区不卡 | 黄色片网站在线观看 | 亚洲精品色 | 欧美日韩亚洲一区二区 | 国产精品久久久久亚洲 | 人人草人人干 | 2021国产精品系列一区二区 | 免费看aa | 亚洲小视频在线 | 免费看搡女人的视频 | 91久久国产精品视频 | 免费aⅴ在线| 亚洲精品色综合久久久 | 午夜精品福利在线 | 一级一级毛片看看 | 天天操天天干天天拍 | 亚洲精品免费日日日夜夜夜夜 | 日日干狠狠操 | 色久天| 2019精品国产品免费观看 | 久久视频这里只有精品35 | 特一级黄| 99热9| 久草热草| 日韩有码第一页 | 免费一看一级欧美 | 香蕉视频在线观看国产 | 99久久国产综合精麻豆 | 欧美久久影院 | 99热这里只有精品88 | 不卡在线播放 | 久久精品国产一区二区 | 日本一级毛片a免费播放 | 欧美亚洲高清日韩成人 | 日日噜噜噜夜夜爽爽狠狠图片 | s级毛片| 久久国产亚洲精品 |