# Best practice for using system.tag.tagQueryHistory

**URL:** <https://forum.inductiveautomation.com/t/best-practice-for-using-system-tag-tagqueryhistory/116638>\
**Category:** Ignition\
**Tags:** ignition81, scripting, perspective\
**Created:** [August 3, 2026, 8:52pm UTC](https://forum.inductiveautomation.com/t/best-practice-for-using-system-tag-tagqueryhistory/116638 "2026-08-03T20:52:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdemaris](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdemaris/32/54639_2.png) [@mdemaris](https://forum.inductiveautomation.com/u/mdemaris)\
**Post date:** [August 3, 2026, 8:52pm UTC](https://forum.inductiveautomation.com/t/best-practice-for-using-system-tag-tagqueryhistory/116638/1 "2026-08-03T20:52:05Z")

</div>

Hi all,

I am using a Time Series chart to display tag history information. The users would like to be able to see a wide time range as they look for anomalies, then zoom in with more data points for a better idea of what's going on in the process.  
Using `system.tag.queryTagHistory` - I set the `intervalSeconds` and `returnSize` based on the length of time between the selected start and end dates, and the `aggregationMode = 'MinMax'`, but I just found out when I tried to get a range of three days, with a few tags selected, the processor was almost maxed and the queries were taking one to four minutes - according to the logs, and I never got the data charted.  
All the items are pretty much scripted, from a `root.custom.pens` object, to the chart's series and trends.  
I'm curious if there is a better way to pull tag history with custom return sizes or intervals that is less processor intensive.

---

<div class="post-metadata">

**Author:** ![louagejasper](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/louagejasper/32/86311_2.png) [@louagejasper](https://forum.inductiveautomation.com/u/louagejasper)\
**Post date:** [August 4, 2026, 3:33pm UTC](https://forum.inductiveautomation.com/t/best-practice-for-using-system-tag-tagqueryhistory/116638/2 "2026-08-04T15:33:21Z")

</div>

What Ignition version are you using? And what database to store the values?

---

<div class="post-metadata">

**Author:** ![mdemaris](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdemaris/32/54639_2.png) [@mdemaris](https://forum.inductiveautomation.com/u/mdemaris)\
**Post date:** [August 4, 2026, 4:38pm UTC](https://forum.inductiveautomation.com/t/best-practice-for-using-system-tag-tagqueryhistory/116638/3 "2026-08-04T16:38:24Z")

</div>

8.1.52 and SQL Server 2022

---

<div class="post-metadata">

**Author:** ![louagejasper](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/louagejasper/32/86311_2.png) [@louagejasper](https://forum.inductiveautomation.com/u/louagejasper)\
**Post date:** [August 5, 2026, 7:47am UTC](https://forum.inductiveautomation.com/t/best-practice-for-using-system-tag-tagqueryhistory/116638/4 "2026-08-05T07:47:27Z")

</div>

Okay, normally that should not be a problem, but sounds like you're not running this on beefy hardware then.

Any chance to upgrade to 8.3 and use the system.historian function? That runs aggregation in the database.

Here you have some more explanation:

[![](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/f/3f28eed2ddb9ca710aa720cf1bb90dd5f8a9bc1c.jpeg "Ignition’s 8.3 New Historian API Explained (and how to use it)") ](https://www.youtube.com/watch?v=qWRpDiBvPmU)

---

<div class="post-metadata">

**Author:** ![mdemaris](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mdemaris/32/54639_2.png) [@mdemaris](https://forum.inductiveautomation.com/u/mdemaris)\
**Post date:** [August 5, 2026, 3:48pm UTC](https://forum.inductiveautomation.com/t/best-practice-for-using-system-tag-tagqueryhistory/116638/5 "2026-08-05T15:48:23Z")

</div>

> [@louagejasper](#):
>
> Any chance to upgrade to 8.3

Not for a while. We are looking into it.

> [@louagejasper](#):
>
> beefy hardware

Our systems are all run on VMs. I could ask about increasing the resources for the Gateway and SQL Server.

---

<div class="post-metadata">

**Author:** ![louagejasper](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/louagejasper/32/86311_2.png) [@louagejasper](https://forum.inductiveautomation.com/u/louagejasper)\
**Post date:** [August 5, 2026, 8:15pm UTC](https://forum.inductiveautomation.com/t/best-practice-for-using-system-tag-tagqueryhistory/116638/6 "2026-08-05T20:15:14Z")

</div>

> [@mdemaris](#):
>
> I could ask about increasing the resources for the Gateway and SQL Server.

Well, what you are requiring does not seem crazy at all, so normally, it should be very fast for data of just a few days. It's starts getting slow for a month of data mostly, so I would look into your hardware and network, to see if there is an issue there.

---

<div class="post-metadata">

**Author:** ![Chris\_Bingham](https://avatars.discourse-cdn.com/v4/letter/c/e5b9ba/32.png) [@Chris\_Bingham](https://forum.inductiveautomation.com/u/Chris_Bingham)\
**Post date:** [August 6, 2026, 2:58am UTC](https://forum.inductiveautomation.com/t/best-practice-for-using-system-tag-tagqueryhistory/116638/7 "2026-08-06T02:58:42Z")

</div>

> [@mdemaris](#):
>
> The users would like to be able to see a wide time range as they look for anomalies, then zoom in with more data points for a better idea of what's going on in the process.

Consider adding additional logging within your scripts. Ensure you're correctly limiting the number of queries / minute, limiting the number of points returned, etc.

You might also experiment with the PowerChart (which has this functionality baked-in) to compare results with your approach.
