日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

Oracle大數(shù)據(jù)量查詢實(shí)際分析

系統(tǒng) 2113 0

Oracle數(shù)據(jù)庫(kù):

剛做一張5000萬(wàn)條數(shù)據(jù)的數(shù)據(jù)抽取,當(dāng)前表同時(shí)還在繼續(xù)insert操作,每分鐘幾百條數(shù)據(jù)。

該表按照時(shí)間,以月份為單位做的表分區(qū),沒(méi)有任何索引,當(dāng)前共有14個(gè)字段,平均每個(gè)字段30個(gè)字節(jié)。當(dāng)前表分區(qū)從201101到201512每月一個(gè)分區(qū)

測(cè)試服務(wù)器:xeno 5650,32核cpu,win2003操作系統(tǒng),物理內(nèi)存16G;測(cè)試工具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條數(shù)據(jù)為段進(jìn)行查詢,查詢一次2分鐘16秒;

后來(lái)查20條,2分鐘14秒;基本跟條數(shù)無(wú)關(guān)。


2.后來(lái)把最小時(shí)間寫成固定的:

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());

查詢時(shí)間 1分34秒。


3.不加分區(qū)查詢

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?

查詢時(shí)間:3分29秒,共1426條


4.添加分區(qū)查詢

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?


添加分區(qū)后查詢:17s,共1426條


所以加分區(qū)后的查詢效率提高十幾倍,所以大數(shù)據(jù)量建立分區(qū)表是相當(dāng)重要的。




?

Oracle大數(shù)據(jù)量查詢實(shí)際分析


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號(hào)聯(lián)系: 360901061

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

【本文對(duì)您有幫助就好】

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

發(fā)表我的評(píng)論
最新評(píng)論 總共0條評(píng)論
主站蜘蛛池模板: 松桃| 浏阳市| 绥芬河市| 伊金霍洛旗| 镇坪县| 长治县| 宜黄县| 台中市| 南乐县| 南投县| 剑川县| 鄯善县| 锡林浩特市| 昆明市| 获嘉县| 芮城县| 鹤峰县| 米易县| 盖州市| 施甸县| 夏津县| 会东县| 桂阳县| 江北区| 新昌县| 神农架林区| 西贡区| 丰镇市| 东明县| 宜阳县| 多伦县| 翁牛特旗| 阳高县| 沙河市| 驻马店市| 丽江市| 吴堡县| 青川县| 花垣县| 明光市| 东乡|