Nicolas FROIDURE
Web Platform Architect
Comparing two time series databases
Series of measures representing the evolution of a value overtime
Open-source project by the Apache Software Foundation
Mature, feature complete open-source
project
Working with 13G (73M points) of data on a dockerized local environment
Counting each sensors data points
# X results in 0.13s to 0.05s
SELECT "sensor", "name", SUM("count") as "count"
FROM "raw_data" GROUP BY "sensor", "name"
# 120 buckets in 21.6488s to 18.571s
GET /diagrams-data-v1-2020.*/_search
{
"query": {
"match_all": {}
},
"size": 1,
"aggs": {
"sensors": {
"terms": {
"field": "sensorId",
"size": 200
},
"aggs": {
"count": {
"value_count": {
"field": "value"
}
}
}
}
}
}
# 10 results in 0.28s to 0.10s
SELECT FLOOR("__time" to HOUR) AS HourTime,
"sensor", "name", SUM("count") as "count",
AVG("value") as "value"
FROM "raw_data"
WHERE "__time" BETWEEN
TIMESTAMP '2020-09-15 00:00:00'
AND TIMESTAMP '2020-09-16 00:00:00'
AND "sensor" = '04c140cd-71b8-470f-97ac-6901007c9176'
GROUP BY 1, "sensor", "name"
# 10 buckets in 0.234s to 0.070s
GET /diagrams-data-v1-2020.*/_search
{
"query": {
"bool": {
"filter": [
{
"term": {
"sensorId": {
"value": "04c140cd-71b8-470f-97ac-6901007c9176"
}
}
},
{
"range": {
"timestamp": {
"gte": "2020-09-15T00:00:00Z",
"lte": "2020-09-16T00:00:00Z",
"format": "strict_date_optional_time_nanos"
}
}
}
]
}
},
"size": 1,
"aggs": {
"data": {
"date_histogram": {
"field": "timestamp",
"calendar_interval": "hour"
}
}
}
}
# 577 results in 0.17s to 0.13s
SELECT FLOOR("__time" to MINUTE) AS MinuteTime,
"sensor", "name", SUM("count") as "count",
AVG("value") as "value"
FROM "raw_data"
WHERE "__time" BETWEEN
TIMESTAMP '2020-09-15 00:00:00'
AND TIMESTAMP '2020-09-16 00:00:00'
AND "sensor" = '04c140cd-71b8-470f-97ac-6901007c9176'
GROUP BY 1, "sensor", "name"
# 577 buckets in 0.146 to 0.102s
GET /diagrams-data-v1-2020.*/_search
{
"query": {
"bool": {
"filter": [
{
"term": {
"sensorId": {
"value": "04c140cd-71b8-470f-97ac-6901007c9176"
}
}
},
{
"range": {
"timestamp": {
"gte": "2020-09-15T00:00:00Z",
"lte": "2020-09-16T00:00:00Z",
"format": "strict_date_optional_time_nanos"
}
}
}
]
}
},
"size": 1,
"aggs": {
"data": {
"date_histogram": {
"field": "timestamp",
"calendar_interval": "minute"
}
}
}
}
# 97,823 results in 3.02s
SELECT FLOOR("__time" to MINUTE) AS MinuteTime,
"sensor", "name", SUM("count") as "count",
AVG("value") as "value"
FROM "raw_data"
WHERE "__time" BETWEEN
TIMESTAMP '2020-09-15 00:00:00'
AND TIMESTAMP '2020-09-16 00:00:00'
GROUP BY 1, "sensor", "name"
# too_many_buckets_exception
GET /diagrams-data-v1-2020.*/_search
{
"query": {
"bool": {
"filter": [
{
"range": {
"timestamp": {
"gte": "2020-09-15T00:00:00Z",
"lte": "2020-09-16T00:00:00Z",
"format": "strict_date_optional_time_nanos"
}
}
}
]
}
},
"size": 1,
"aggs": {
"data": {
"date_histogram": {
"field": "timestamp",
"calendar_interval": "minute"
},
"aggs": {
"sensors": {
"terms": {
"field": "sensorId",
"size": 300
}
}
}
}
}
}
By Nicolas FROIDURE
A little comparison between those two options for Time Series