本篇文章為大家展示了如何實(shí)現(xiàn)ClickHouse與 Elasticsearch聚合性能對(duì)比測(cè)試,內(nèi)容簡(jiǎn)明扼要并且容易理解,絕對(duì)能使你眼前一亮,通過(guò)這篇文章的詳細(xì)介紹希望你能有所收獲。
為金壇等地區(qū)用戶(hù)提供了全套網(wǎng)頁(yè)設(shè)計(jì)制作服務(wù),及金壇網(wǎng)站建設(shè)行業(yè)解決方案。主營(yíng)業(yè)務(wù)為做網(wǎng)站、成都網(wǎng)站設(shè)計(jì)、金壇網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專(zhuān)業(yè)、用心的態(tài)度為用戶(hù)提供真誠(chéng)的服務(wù)。我們深信只要達(dá)到每一位用戶(hù)的要求,就會(huì)得到認(rèn)可,從而選擇與我們長(zhǎng)期合作。這樣,我們也可以走得更遠(yuǎn)!
Elasticsearch以其優(yōu)秀的分布式架構(gòu)與全文搜索引擎等特點(diǎn)在機(jī)器數(shù)據(jù)的存儲(chǔ)、分析領(lǐng)域廣為使用,但隨著數(shù)據(jù)量的增長(zhǎng),其聚合分析性能已無(wú)法滿(mǎn)足業(yè)務(wù)需求。而ClickHouse作為一個(gè)高性能的OLAP列式數(shù)據(jù)庫(kù)管理系統(tǒng)有望解決這一痛點(diǎn)。
本文是對(duì)ClickHouse與Elasticsearch聚合性能的簡(jiǎn)單對(duì)比測(cè)試。主要關(guān)注查詢(xún)語(yǔ)句的響應(yīng)時(shí)間,暫不考慮資源占用情況。
組件 | 版本 | CPU | 內(nèi)存 |
---|---|---|---|
ClickHouse | 7.9.0 | 4C | 8G |
Elasticsearch | 20.11.4.13 | 4C | 8G |
使用ClickHouse官方提供的測(cè)試數(shù)據(jù)集,共67G,約6億行。
其中,ClickHouse使用LO_ORDERDATE字段作為分區(qū)鍵,使用LO_ORDERDATE, LO_ORDERKEY作為排序鍵。
# ClickHouse
SELECT LO_SHIPMODE,COUNT() FROM lineorder GROUP BY LO_SHIPMODE ORDER BY COUNT() DESC LIMIT 10
# Elasticsearch
GET lineorder/_search
{
"aggs": {
"1": {
"terms": {
"field": "LO_SHIPMODE.keyword",
"order": {
"_count": "desc"
},
"size": 10
}
}
},
"size": 0
}
# ClickHouse
SELECT toYear(LO_ORDERDATE),COUNT() FROM lineorder GROUP BY toYear(LO_ORDERDATE) FORMAT PrettyCompactMonoBlock
# Elasticsearch
GET lineorder/_search
{
"aggs": {
"2": {
"date_histogram": {
"field": "LO_ORDERDATE",
"calendar_interval":"1y",
"format":"yyyy-MM-dd"
}
}
},
"size": 0
}
# ClickHouse
SELECT LO_ORDERDATE,LO_ORDERKEY,LO_SHIPMODE,LO_ORDERPRIORITY,LO_COMMITDATE FROM lineorder WHERE LO_ORDERDATE >= '1992-01-01' AND LO_ORDERDATE < '1993-01-01' ORDER BY LO_ORDERDATE LIMIT 500
# Elasticsearch
GET lineorder/_search
{
"size": 500,
"sort": [
{
"timestamp": {
"order": "desc",
"unmapped_type": "boolean"
}
}
],
"query": {
"bool": {
"must": [],
"filter": [
{
"match_all": {}
},
{
"match_all": {}
},
{
"range": {
"LO_ORDERDATE": {
"gte": "1992-01-01",
"lte": "1993-01-01",
"format": "strict_date_optional_time"
}
}
}
],
"should": [],
"must_not": []
}
}
}
# ClickHouse
SELECT toYear(LO_ORDERDATE),LO_SHIPMODE,COUNT() FROM lineorder GROUP BY toYear(LO_ORDERDATE),LO_SHIPMODE ORDER BY toYear(LO_ORDERDATE) FORMAT PrettyCompactMonoBlock
# Elasticsearch
GET lineorder/_search
{
"aggs": {
"3": {
"terms": {
"field": "LO_SHIPMODE.keyword",
"order": {
"_count": "desc"
},
"size": 10
},
"aggs": {
"2": {
"date_histogram": {
"field": "LO_ORDERDATE",
"calendar_interval": "1y",
"time_zone": "Asia/Shanghai",
"min_doc_count": 1
}
}
}
}
},
"size": 0
}
# ClickHouse
SELECT toYear(LO_ORDERDATE),LO_SHIPMODE,COUNT() FROM lineorder GROUP BY toYear(LO_ORDERDATE),LO_SHIPMODE ORDER BY toYear(LO_ORDERDATE) FORMAT PrettyCompactMonoBlock
# Elasticsearch
GET lineorder/_search
{
"aggs": {
"3": {
"terms": {
"field": "LO_SHIPMODE.keyword",
"order": {
"_count": "desc"
},
"size": 10
},
"aggs": {
"2": {
"date_histogram": {
"field": "LO_ORDERDATE",
"calendar_interval": "1y",
"time_zone": "Asia/Shanghai",
"min_doc_count": 1
}
}
}
}
},
"size": 0
}
# ClickHouse
SELECT LO_SHIPMODE,COUNT(LO_SHIPMODE),LO_ORDERPRIORITY,COUNT(LO_ORDERPRIORITY) FROM lineorder GROUP BY LO_SHIPMODE,LO_ORDERPRIORITY ORDER BY COUNT(LO_SHIPMODE),COUNT(LO_ORDERPRIORITY) LIMIT 5 BY LO_SHIPMODE,LO_ORDERPRIORITY
# Elasticsearch
GET lineorder/_search
{
"aggs": {
"2": {
"terms": {
"field": "LO_SHIPMODE.keyword",
"order": {
"_count": "desc"
},
"size": 5
},
"aggs": {
"3": {
"terms": {
"field": "LO_ORDERPRIORITY.keyword",
"order": {
"_count": "desc"
},
"size": 5
}
}
}
}
},
"size": 0
}
聚合場(chǎng)景 | ck(ms) | es(ms) | 性能對(duì)比 |
---|---|---|---|
基于時(shí)間的多字段聚合 | 5506 | 15599 | 近3倍 |
多個(gè)字段按年進(jìn)行計(jì)數(shù)(數(shù)據(jù)表) | 381 | 6267 | 16倍多 |
某字段出現(xiàn)次數(shù) TOP 10(餅圖) | 4048 | 7317 | 近2倍 |
某字段按年進(jìn)行計(jì)數(shù)(時(shí)間趨勢(shì)圖) | 901 | 23257 | 25倍多 |
聚合嵌套(非時(shí)間字段) | 6937 | 15767 | 2倍多 |
相同數(shù)據(jù)量下,ClickHouse的聚合性能都要優(yōu)于Elasticsearch,且如果基于排序鍵進(jìn)行聚合,性能更好,是ES的數(shù)倍。
此外,ClickHouse的SummaryMergeTree、AggregatingMergeTree表引擎支持后臺(tái)自動(dòng)聚合數(shù)據(jù),所以在某些場(chǎng)景下其聚合分析性能會(huì)更優(yōu)。
上述內(nèi)容就是如何實(shí)現(xiàn)ClickHouse與 Elasticsearch聚合性能對(duì)比測(cè)試,你們學(xué)到知識(shí)或技能了嗎?如果還想學(xué)到更多技能或者豐富自己的知識(shí)儲(chǔ)備,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。
分享題目:如何實(shí)現(xiàn)ClickHouse與Elasticsearch聚合性能對(duì)比測(cè)試
本文地址:http://muchs.cn/article20/gddico.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信公眾號(hào)、網(wǎng)站策劃、商城網(wǎng)站、網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì)公司、品牌網(wǎng)站設(shè)計(jì)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)