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

Oracle大數據量查詢實際分析

系統 2089 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條評論
主站蜘蛛池模板: 日本最新免费二区 | 亚欧美综合 | 亚洲qingse中文字幕久久 | 9966久久精品免费看国产 | 羞羞视频网| 黄片毛片在线看 | 婷婷色网站 | 欧美激情在线视频播放 | 亚洲色妞 | 91福利视频在线 | 久久综合五月 | 99热这里只有精品久久免费 | 亚欧洲精品bb | 精品久久久久久久久免费影院 | 久青草免费视频 | www.五月天婷婷 | a毛片成人免费全部播放 | 婷婷玖玖| 国产日韩不卡免费精品视频 | 天天做夜夜做久久做狠狠 | 九九精品在线播放 | 色婷婷色 | 久久在线一区 | 亚洲国产精久久久久久久 | 亚洲欧美日韩国产专区一区 | 欧美开嫩苞实拍视频在线观看 | 91久久国产青草亚洲 | 日本在线不卡免费 | 亚洲最大成人网 色香蕉 | 精品在线免费视频 | 精品国产午夜久久久久九九 | 欧美日韩久久毛片 | 国产日韩精品一区二区在线观看 | 夜夜夜夜夜夜夜猛噜噜噜噜噜噜 | 四虎在线网站 | 在线观看日韩一区 | 成人亚洲视频在线观看 | 午夜欧美在线 | 亚洲国产精品婷婷久久 | 国内精品久久久久激情影院 | 日本在线观看a |