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

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條評論
主站蜘蛛池模板: 国产日韩中文字幕 | 久久99精品一级毛片 | 国产成人99久久亚洲综合精品 | 亚洲精品一区二区三区在线看 | 99热这里只有精 | 亚洲欧洲国产精品 | 久久精品免费全国观看国产 | 国产精品福利社 | 在线视频 二区 | 精品久久在线 | 国产性做久久久久久 | 国产综合精品久久久久成人影 | 亚洲成a人v在线观看 | 色综合久久六月婷婷中文字幕 | 在线a亚洲视频播放在线观看 | 欧美高清不卡午夜精品免费视频 | 第一色区 | 国内自拍tv在线 | 四虎影院海外永久 | 国产精品你懂的在线播放 | 国产h视频免费观看 | 99九九99九九九视频精品 | 亚洲视频中文 | 久久婷婷色 | 99热欧美| 久久精品动漫 | 欧美日韩视频精品一区二区 | 亚洲在线小视频 | 国产成人综合亚洲 | 91资源在线播放 | 2021久久精品永久免费 | 九九福利视频 | 国产精品成人一区二区不卡 | 久久91亚洲精品中文字幕 | 久久成人综合网 | 亚洲欧美在线播放 | 亚洲视频在线一区二区 | 日本高清不卡免费 | 国产国产成人精品久久 | 欧美一区a | 九九热视频在线免费观看 |