最近公司準備把記憶體資料庫和資料庫換成國產的數蠶資料庫,老大讓我來測驗一下性能,周末正好加個小班小試了一下,
環境準備:
官方提供的包括的linux和windows平臺專業版各一套,我這里測驗是windows平臺使用Windows 10系統,
開發機器:CPU i7 8700, 記憶體 16G, 256G固態盤,
資料準備:
使用100000,1000000條包含整數型別,浮點型別,日期型別,字串型別的資料,其中name,date,value含有重復值,構造的資料表為id,name,date,value的欄位表,
記憶體資料庫
測驗內容包含:插入,查詢
插入分別使用insert, sql檔案和import功能,
這個資料庫的sql和標準有一些不太一致的地方,還好在線檔案寫得很清晰,過了一遍就大概齊了解區別了,
運行sct_local_mem.exe,或者運行sct_s_mem.exe再運行sct_c_mem.exe連接服務端,
以下測驗在sct_local_mem.exe上,經測驗通過網路速度對這部分插入測驗幾乎沒有影響,
首先構造資料表
create table test(id u32(false), name string(true), date date(true), value float(true));
insert使用資料庫序列函式seq可以直接生成序列,
insert into test (id, name, date, value) select seq(100000), constants("張三",100000), constants (date(),100000), seq(100000)+1.0;
執行時間:
execute time: 743390 us 134518條每秒
使用
select "insert into test (id,name,date,value) values(" + x2str(id) + ",\"" + name + "\",\"" + x2str(date) + "\"," + x2str(value) + ");" as sql from test export as csv path="test.sql";
生成sql檔案,去除第一行
Sql檔案內容為100000行
insert into test(id, name, date, value) values(0,"張三","2020-11-12",1.000000);
insert into test(id, name, date, value) values(1,"張三","2020-11-12",2.000000);
insert into test(id, name, date, value) values(2,"張三","2020-11-12",3.000000);
insert into test(id, name, date, value) values(3,"張三","2020-11-12",4.000000);
…
使用exec 執行sql檔案
exec "test.sql"
執行時間:
execute time: 12597752 us 7938條每秒
使用import加載csv時間
select * from test export as csv path="test.csv";
import test from csv path="test.csv";
執行時間:
execute time: 875321 us 114285條每秒
對應百萬結果:
insert select 時間: execute time: 7906557 us 126422 條每秒
exec 時間: execute time: 125150944 us 7990條每秒
import time: execute time: 9379922 us 106610 條每秒
大體上可以看出時間上是亞線性關系穩定的增加,
查詢測驗(僅在1000000資料下):
select id,date from test where first 100;
execute time: 447 us
select id,date from test where first 10000;
execute time: 7067 us
select id,date from test where id==10000;
execute time: 345 us
查詢速度可以媲美nosql資料庫
硬碟資料庫
構造表
create table test(id u32(false), name string16(true), date date(true), value float(true));
insert插入資料
insert into test (id, name, date, value) select seq(100000), constants(“張三”,100000), constants (date(),100000), seq(100000)+1.0;
執行時間:
execute time: 247098217 us 平均404條每秒
exec sql執行時間:
exec "test.sql";
execute time: 274124784 us 平均364條每秒
資料無import命令使用load命令替代
load test from csv path="test.csv";
load執行時間:
execute time: 2055357 us 平均48543 條每秒
百萬insert和exec時間比較長就沒有測驗,只測驗load
load執行時間:
execute time: 18544048 us 平均54054條每秒
查詢測驗(僅在1000000資料下):
select id,date from test where first 100;
execute time: 1256 us
select id,date from test where first 10000;
execute time: 59253 us
select id,date from test where id==10000;
execute time: 465 us
結論
整體看對比記憶體資料庫硬碟直接insert陳述句插入速度慢了20倍左右,
load/import匯入資料比記憶體資料庫只慢了一倍左右,
查詢速度少量查詢慢了約一倍,查詢越多速度慢的越多,
記憶體資料庫速度上優勢很明顯,資料庫產品整體上性能比較穩定,查詢性能非常出色,適合多讀少寫的業務場景,
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/215298.html
標籤:其他
