Tracking Down SQL History Queries

Is there a way to tell which tags are being queried in the database statistics screen? I’m trying to track down some really long history queries but I can’t tell where they are coming from because the tag IDs are listed as question marks.

Also, on a side note, I notice that this query has an OR in it. Queries with ORs are typically pretty inefficient, has anyone looked into what this query would look like with a UNION?

Ok, so I finally tracked this down and figure out where my issue was. Now I have somewhat of a feature request:

I have a sparkline chart on a template with the tag history start and end date bound to indirect tag references. When the page would load the tag quality was bad until the tags were finally read I guess… I’m not 100% sure, but I know it had to do with bad quality. Anyway, what would happen was that the sparkline chart would try and bring back multiple years worth of data and completely fill up the RAM on the server and the server would crash. I changed the bindings to expression bindings and did a check on the quality first, if the quality was bad then I just bring back an hours worth of data. That fixed my issue.

I think there should be some kind of historical time limit setting on the sparkline charts on the tag history setting to prevent things like that from happening. Similar to how you can limit number of days you can select on the easy chart.