# How to find where a query came from

**URL:** <https://forum.inductiveautomation.com/t/how-to-find-where-a-query-came-from/44786>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [March 23, 2021, 10:49am UTC](https://forum.inductiveautomation.com/t/how-to-find-where-a-query-came-from/44786 "2021-03-23T10:49:37Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [March 23, 2021, 10:49am UTC](https://forum.inductiveautomation.com/t/how-to-find-where-a-query-came-from/44786/1 "2021-03-23T10:49:37Z")

</div>

Hello folks,

I’m trying to figure out where a query comes from, but to no avail.  
Using the general log to monitor what’s going on:

```auto
mysql -e "set global general_log = ON"
tail -f /var/lib/mysql/logfile.log

```

I get this :

```auto
210323 9:13:27 146 Query SELECT 1
                    991 Query SELECT zone_num FROM param_zone
                    146 Query SELECT 1
                    957 Query SELECT 1
                    957 Query SELECT zone_num FROM param_zone
210323 9:13:28 991 Query SELECT 1
                    991 Query SELECT zone_num FROM param_zone
                    957 Query SELECT 1
                    957 Query SELECT zone_num FROM param_zone
210323 9:13:29 991 Query SELECT 1
                    991 Query SELECT zone_num FROM param_zone
                    957 Query SELECT 1
                    957 Query SELECT zone_num FROM param_zone
210323 9:13:30 991 Query SELECT 1
                    991 Query SELECT zone_num FROM param_zone
                    957 Query SELECT 1
                    957 Query SELECT zone_num FROM param_zone
210323 9:13:31 991 Query SELECT 1
                    991 Query SELECT zone_num FROM param_zone
                    957 Query SELECT 1
210323 9:13:32 957 Query SELECT zone_num FROM param_zone
                    991 Query SELECT 1
                    991 Query SELECT zone_num FROM param_zone
210323 9:13:33 957 Query SELECT 1
                    957 Query SELECT zone_num FROM param_zone
                    991 Query SELECT 1
                    991 Query SELECT zone_num FROM param_zone
210323 9:13:34 957 Query SELECT 1
                    991 Query SELECT 1
                    991 Query SELECT zone_num FROM param_zone
                    957 Query SELECT zone_num FROM param_zone 

```

So, there’s a “SELECT 1” every 10 seconds, then another one along with a “SELECT zone\_num FROM param\_zone” every second.  
This happens with no client opened, and only with one of several basically identical projects. We’re using MariaDB.  
I have NO IDEA where those come from.  
I tried searching for those terms, but found nothing.

Might anyone have a few tips on how to go about hunting queries ?

---

<div class="post-metadata">

**Author:** ![zxcslo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zxcslo/32/61610_2.png) [@zxcslo](https://forum.inductiveautomation.com/u/zxcslo)\
**Post date:** [March 23, 2021, 10:57am UTC](https://forum.inductiveautomation.com/t/how-to-find-where-a-query-came-from/44786/2 "2021-03-23T10:57:54Z")

</div>

Edit your database connection on the Ignition server web page and check the ‘Show advanced properties’ checkmark at the bottom.  
In the ‘Connection Testing’ section, you’ll see…

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [March 23, 2021, 1:11pm UTC](https://forum.inductiveautomation.com/t/how-to-find-where-a-query-came-from/44786/3 "2021-03-23T13:11:05Z")

</div>

Thanks,

I figured the 10 seconds one might be some sort of ping (thought should it really be trying to validate a connection when we’re not even attempting to use it ? The “Test while idle?” field is disabled),  
but i’m more concerned about the other query (SELECT zone\_num FROM param\_zone).  
This one makes no sense to me !

---

<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:** [March 23, 2021, 3:06pm UTC](https://forum.inductiveautomation.com/t/how-to-find-where-a-query-came-from/44786/4 "2021-03-23T15:06:13Z")

</div>

If a system wide find doesn’t find it, I would bet it is a tag change script or a sql query tag.  
Export the tag database, then open it with a text editor like Notepad++ and search for the query string.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [March 24, 2021, 8:05am UTC](https://forum.inductiveautomation.com/t/how-to-find-where-a-query-came-from/44786/5 "2021-03-24T08:05:55Z")

</div>

Assuming I did things right, it’s not there either.  
Just to make sure I didn’t miss something: I exported my project’s tags, which gave me a json. I then tried to grep “SELECT” in that json, which yielded nothing.

---

<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:** [March 24, 2021, 11:36am UTC](https://forum.inductiveautomation.com/t/how-to-find-where-a-query-came-from/44786/6 "2021-03-24T11:36:48Z")

</div>

Anything in client tags?

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [March 24, 2021, 12:50pm UTC](https://forum.inductiveautomation.com/t/how-to-find-where-a-query-came-from/44786/7 "2021-03-24T12:50:02Z")

</div>

Do you have any dynamic query generating functions? Something like `"SELECT % FROM %s"` and perhaps its getting filled in with your two values? Query building functions can be helpful but can also make stuff like this hard to track down.

---

<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:** [March 24, 2021, 12:50pm UTC](https://forum.inductiveautomation.com/t/how-to-find-where-a-query-came-from/44786/8 "2021-03-24T12:50:04Z")

</div>

Any Gateway scripts running?

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [March 29, 2021, 6:58am UTC](https://forum.inductiveautomation.com/t/how-to-find-where-a-query-came-from/44786/9 "2021-03-29T06:58:04Z")

</div>

That’s a very good idea, I didn’t think of that.  
I’ll try and find out.

@MMaynard:  
I’m afraid not…

@lrose:  
Yes, but no query involved that looks anything like this.

edit:  
Any way I could isolate things that get called every second or so ?

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [March 29, 2021, 7:13am UTC](https://forum.inductiveautomation.com/t/how-to-find-where-a-query-came-from/44786/10 "2021-03-29T07:13:35Z")

</div>

Another thing:  
I have queries that are just like this one, but with WHERE clauses.  
Any chance the clause might be removed somehow ?

I should add that pretty much none of the code is mine, I’m actually in the process of cleaning and fixing it…  
It makes it hard to know what’s going on.

---

<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:** [March 29, 2021, 11:34am UTC](https://forum.inductiveautomation.com/t/how-to-find-where-a-query-came-from/44786/11 "2021-03-29T11:34:51Z")

</div>

There is no way to isolate things based on their polling rate that I am aware of.

The fact that it happens with no client open and only on a particular project, indicates to me that you should be looking in a Gateway Event Script.

1. Gateway Event Scripts are considered a project resource and so would be isolated to a single project
2. They run on the gateway and so do not require any sessions or clients to be open
3. If these were the result of a Tag Change Script, or Query Tag Polling then it would be across all projects (unless the projects are on separate gateways).
4. Any script on a window would require a client to be running
5. Client Event Scripts require a client to be running

The fact that this is so cyclical would lead me to the Timer Events, particularly those with a 10,000ms delay/rate.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [March 29, 2021, 1:01pm UTC](https://forum.inductiveautomation.com/t/how-to-find-where-a-query-came-from/44786/12 "2021-03-29T13:01:26Z")

</div>

There are only two gateway scripts, one that is running on a 5.000 ms timer, and another one on tag change.  
Neither of those use queries.

---

<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:** [March 29, 2021, 1:34pm UTC](https://forum.inductiveautomation.com/t/how-to-find-where-a-query-came-from/44786/13 "2021-03-29T13:34:49Z")

</div>

Any named queries?

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [March 30, 2021, 8:38am UTC](https://forum.inductiveautomation.com/t/how-to-find-where-a-query-came-from/44786/14 "2021-03-30T08:38:39Z")

</div>

Quite a few indeed, but none of them matches this query.  
I have a couple that look like it, but with extra conditions or columns, things like that.  
besides, I don’t think any of them is called on such a timer, they’re supposed to be called on user interaction…

edit:  
I want to thank you guys for the help, it’s very nice of you.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [March 30, 2021, 12:13pm UTC](https://forum.inductiveautomation.com/t/how-to-find-where-a-query-came-from/44786/15 "2021-03-30T12:13:33Z")

</div>

Perhaps a dumb question but does any other application use this database?

I believe too MySQL can have events that run queries - have you checked this?

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [April 6, 2021, 11:53am UTC](https://forum.inductiveautomation.com/t/how-to-find-where-a-query-came-from/44786/16 "2021-04-06T11:53:05Z")

</div>

No, this db is only used for ignition.

---

<div class="post-metadata">

**Author:** ![CB123](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@CB123](https://forum.inductiveautomation.com/u/CB123)\
**Post date:** [June 10, 2025, 5:35pm UTC](https://forum.inductiveautomation.com/t/how-to-find-where-a-query-came-from/44786/17 "2025-06-10T17:35:52Z")

</div>

I hate to pull up a fairly old thread, but Pascal did you ever figure out why the query you were seeing in the activity wasn't matching up exactly (but pretty close) to your known queries? I have the same concerns with a query I am seeing running very often, it looks fairly generic to me but it could be just what my normal queries look like running. IE it looks like it wants to pull all fields from the sqlth\_1\_data table, but my known queries (exported all tags and NQ to search them) only pull mostly one of the fields. I see it pulls DESC LIMIT 1, which I definitely don't have but maybe that's what a scaler return format really looks like in the backend. I am working on bringing my setup more inline with what I am learning is best practice (IE don't use query tags to start with, if that's the case not sure why they exist). Thanks for any knowledge you can dredge up from this long ago.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [June 10, 2025, 6:36pm UTC](https://forum.inductiveautomation.com/t/how-to-find-where-a-query-came-from/44786/18 "2025-06-10T18:36:55Z")

</div>

That the historian itself. The DESC LIMIT 1 is used to determine the last data point in a time range, typically for a chart.
