性能測試
本文介紹用維基百科英語語料庫的數(shù)據(jù)做性能測試的結(jié)果,包含索引構(gòu)建、單Term查詢、多Term查詢等多項(xiàng)性能測試結(jié)果。
測試實(shí)例規(guī)格
引擎版本:AnalyticDB PostgreSQL 7.0版。
內(nèi)核小版本:v7.1.0.0。
實(shí)例系列:高可用版。
節(jié)點(diǎn)規(guī)格:4 C 32 GB。
節(jié)點(diǎn)數(shù)量:4 Segment。
節(jié)點(diǎn)存儲容量:200 GB。
存儲磁盤類型:ESSD云盤PL1。
Master資源:8 CU。
測試數(shù)據(jù)集
數(shù)據(jù)來源為維基百科英語語料庫的快照,包含500萬條數(shù)據(jù)。下載數(shù)據(jù),請參見測試數(shù)據(jù)。本次測試了1億條數(shù)據(jù)(將本次測試數(shù)據(jù)重復(fù)導(dǎo)入20次)下的性能情況。
數(shù)據(jù)由url、title和body組成。
數(shù)據(jù)格式為JSON。
數(shù)據(jù)大小為2.34 GB。
性能測試結(jié)果
BM25索引構(gòu)建耗時(shí)約為Gin(tsvector)索引耗時(shí)的63%。
在單Term查詢方面,BM25索引的QPS性能為Gin(tsvector)索引的6-7倍。
在多Term查詢方面,BM25索引的QPS性能為Gin(tsvector)索引的6-11倍。
在單Term AND點(diǎn)查詢方面,BM25索引的QPS性能為Gin(tsvector)+btree索引的6-9倍。
在單Term AND范圍查詢方面,BM25索引的QPS性能為Gin(tsvector)+btree索引的1-9倍。
索引構(gòu)建
索引 | 數(shù)據(jù)導(dǎo)入耗時(shí) | 構(gòu)建索引耗時(shí) | 帶索引流式導(dǎo)入耗時(shí) |
BM25 | 24 min | 36 min | 84 min |
Gin(tsvector) | 137 min | 57 min | - |
查詢單個(gè)Term
在body列上查詢包含某個(gè)Term的TOP 20結(jié)果,例如body:"Gabriel Basso"
。這些Term的平均出現(xiàn)頻率為56685(單位:次)。結(jié)果取最大的QPS以及對應(yīng)時(shí)間點(diǎn)的RT。
并發(fā)數(shù) | BM25 | Gin(tsquery) | ||
QPS | RT (ms) | QPS | RT (ms) | |
1 | 158.86 | 6.45 | 25.97 | 38.35 |
5 | 544.43 | 9.19 | 73.92 | 64.35 |
10 | 738.21 | 12.63 | 89.90 | 128.65 |
20 | 863.07 | 20.69 | 172.83 | 262.89 |
30 | 925.02 | 31.05 | 239.74 | 378.18 |
40 | 1234.45 | 39.64 | 203.91 | 616.93 |
查詢多個(gè)Term
在body列上查詢包含多個(gè)Term中任意一個(gè)或多個(gè)的TOP20結(jié)果,例如body:handsworth OR body:cern
。所有的Term都是從數(shù)據(jù)集中提取的,本次結(jié)果排除了罕見的Term(出現(xiàn)次數(shù)少于100次)。每個(gè)查詢所包含的Term數(shù)量符合權(quán)重分布[0.03, 0.15, 0.25, 0.25, 0.15, 0.08, 0.04, 0.03, 0.02]。即有3%的查詢包含1個(gè)Term、15%的查詢包含2個(gè)Term等。
并發(fā)數(shù) | BM25 | GIN(tsvector) | ||
QPS | RT (ms) | QPS | RT (ms) | |
1 | 216.88 | 4.54 | 31.97 | 31.49 |
5 | 842.12 | 5.86 | 104.89 | 47.27 |
10 | 1161.79 | 8.58 | 112.89 | 87.40 |
20 | 1332.61 | 15.03 | 118.87 | 159.25 |
30 | 1380.56 | 21.66 | 120.93 | 264.10 |
40 | 1470.47 | 26.73 | 131.87 | 341.69 |
查詢單Term AND點(diǎn)查
點(diǎn)查條件只命中一條數(shù)據(jù)。
SELECT * FROM articles ORDER BY body @@@ pgsearch.config('body:"David" AND id:80000000');
SELECT * FROM articles_gin WHERE body_ts @@ to_tsquery('David') AND id = '80000000';
并發(fā)數(shù) | BM25 | GIN(tsvector)+Btree | ||
QPS | RT (ms) | QPS | RT (ms) | |
1 | 342.92 | 2.81 | 2.00 | 985.66 |
5 | 1434.90 | 3.30 | 4.99 | 2401.95 |
10 | 2293.54 | 4.21 | 6.99 | 4306.61 |
20 | 3084.70 | 6.32 | 13.98 | 8536.26 |
30 | 2835.97 | 10.38 | 19.98 | 12565.44 |
40 | 3081.71 | 12.78 | 24.97 | 17342.22 |
查詢單Term AND范圍查詢
范圍查詢過濾掉99.99%的數(shù)據(jù),命中1萬條數(shù)據(jù)。
SELECT * FROM articles WHERE body @@ pgsearch.config('body:"David" AND id:[110000 TO 120000]');
SELECT * FROM articles_gin WHERE body_ts @@ to_tsquery('David') AND id >= '110000' AND id <= '120000';
并發(fā)數(shù) | BM25 | GIN(tsvector)+Btree | ||
QPS | RT (ms) | QPS | RT (ms) | |
1 | 9.99 | 110.55 | 1.00 | 1189.95 |
5 | 22.97 | 229.57 | 4.99 | 2074.63 |
10 | 25.97 | 451.81 | 8.99 | 4236.33 |
20 | 32.97 | 951.86 | 14.99 | 8674.06 |
30 | 29.97 | 1366.22 | 19.98 | 13458.88 |
40 | 39.97 | 2071.66 | 32.96 | 18251.81 |