# Audit the historian for most active tags

**URL:** <https://forum.inductiveautomation.com/t/audit-the-historian-for-most-active-tags/59174>\
**Category:** Ignition\
**Tags:** ignition81, scripting\
**Created:** [May 3, 2022, 6:41pm UTC](https://forum.inductiveautomation.com/t/audit-the-historian-for-most-active-tags/59174 "2022-05-03T18:41:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cory.grube](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cory.grube/32/20476_2.png) [@Cory.grube](https://forum.inductiveautomation.com/u/Cory.grube)\
**Post date:** [May 3, 2022, 6:41pm UTC](https://forum.inductiveautomation.com/t/audit-the-historian-for-most-active-tags/59174/1 "2022-05-03T18:41:56Z")

</div>

I’m looking for a simple way to identify which tags log the most data to the historian. This is for a large system, north of 10k historian tags.

It’s easy enough to spot check an individual tag using `system.tag.queryTagCalculation()` and get a count for a time range. For instance, I can check if a tag logs 2 values/hour or 2000 values/hour and adjust history configurations accordingly. I could take it a step farther and iterate through all of my tags, but this feels like a messy approach (not to mention would take a good long while to run).

Does anyone have a more comprehensive or efficient method that’s worked for them? Perhaps something that can be run as a report or query? 🤞

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [May 3, 2022, 6:53pm UTC](https://forum.inductiveautomation.com/t/audit-the-historian-for-most-active-tags/59174/2 "2022-05-03T18:53:30Z")

</div>

Quick spot check could be something like

> SELECT  
> tagid, count(tagid) as cnt  
> FROM  
> [sqlt\_data\_\*\*\*\*\*\*\*\*]  
> group by tagid

Replace [sqlt\_data\_\*\*\*\*\*\*\*\*] with the name of one of your history tables.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [May 3, 2022, 6:56pm UTC](https://forum.inductiveautomation.com/t/audit-the-historian-for-most-active-tags/59174/3 "2022-05-03T18:56:24Z")

</div>

For outside of the database, you could use, `system.tag.browseHistoricalTags` in conjunction with `system.tag.getConfiguration` to build a report of tags and sample rates.

You could even automate making the change with `system.tag.configure` but that might be a little too hands off.

---

<div class="post-metadata">

**Author:** ![Cory.grube](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cory.grube/32/20476_2.png) [@Cory.grube](https://forum.inductiveautomation.com/u/Cory.grube)\
**Post date:** [May 3, 2022, 7:19pm UTC](https://forum.inductiveautomation.com/t/audit-the-historian-for-most-active-tags/59174/4 "2022-05-03T19:19:58Z")

</div>

Should have known SQL would be the easy path here haha. This is a great start, thank you!

When I have some time I’ll expand on this to tie in tag paths etc

---

<div class="post-metadata">

**Author:** ![josborn](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@josborn](https://forum.inductiveautomation.com/u/josborn)\
**Post date:** [May 3, 2022, 7:22pm UTC](https://forum.inductiveautomation.com/t/audit-the-historian-for-most-active-tags/59174/5 "2022-05-03T19:22:34Z")

</div>

To expand on @MMaynard’s answer.

```auto
SELECT tagpath, count(tagid) as counts
  FROM [sqlth_1_data]
  inner join [sqlth_te] on [sqlth_1_data].tagid = [sqlth_te].id 
  group by tagpath
  order by counts desc

```
