queryTagHistory performance issues

When using queryTagHistory for more than the past two months, the performance is very poor. We are reading two tags with 1h aggregation period and two tags with 24h aggregation period. When selecting 6 months of data, the query takes almost 40 seconds. No actual memory/cpu load has been observed on the SQL server or ignition which are installed on separate machines.
The same queries for just two months, take approx. 3 seconds.
Ignition version: 8.1.36
query.py (4.5 KB)

You're running an SQL query for every date in the range! Why not run one query for the date range and manipulate the result?

1 Like