Aggregation of multiple timeseries


QuasarDB allows for aggregations of data stored in multiple timeseries in a single query by making use of Tags. This allows for concise and high-performance execution of aggregations. This article explains how to set up your data model in such a way to support this, and how to write queries that make use of this.

Tags and Timeseries

QuasarDB uses a concept called "Tags" for efficient indexing and querying of stored entities. Because timeseries in QuasarDB are just another entry type, we can leverage this for timeseries by providing tags upon construction.

Note - tags apply to entire timeseries, not individual data points / rows stored inside timeseries.

In the Python API for example, if we were to create two timeseries with the tag "exchange=nasdaq", it would look like this:

import quasardb

# Initialize timeseries with two columns
c = quasardb.Cluster(uri="qdb://")
ts = c.ts("")
cols = ts.create([quasardb.TimeSeries.Int64ColumnInfo("bid"),

# Attach tag to it

Tags and Queries

After we have created multiple timeseries and have seeded it with data, we can use the query api to perform calculations on all timeseries that match a certain tag. If we would want to calculate the average bid of all stocks on nasdaq, we would perform a query such as this:

qdbsh!> select arithmetic_mean(bid) from find(tag='nasdaq') in range (2018, 2019)

timestamp timeseries arithmetic_mean(bid)
2018-01-01T00:00:00.000000000Z 49
2018-01-01T00:00:00.000000000Z 47

More information

We full example that shows you how to do this using the Python API is available in the Python examples repository.


Was this article helpful?
0 out of 0 found this helpful