# SQL Query Monitoring

**URL:** <https://forum.inductiveautomation.com/t/sql-query-monitoring/58646>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [April 20, 2022, 6:27pm UTC](https://forum.inductiveautomation.com/t/sql-query-monitoring/58646 "2022-04-20T18:27:26Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![kaushik.shah](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@kaushik.shah](https://forum.inductiveautomation.com/u/kaushik.shah)\
**Post date:** [April 20, 2022, 6:27pm UTC](https://forum.inductiveautomation.com/t/sql-query-monitoring/58646/1 "2022-04-20T18:27:26Z")

</div>

I know there are query monitoring tools from different database providers but I was wondering if there was a way to log/print all the queries requested by Ignition to any database connection. May be something within system.db ?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 20, 2022, 6:41pm UTC](https://forum.inductiveautomation.com/t/sql-query-monitoring/58646/2 "2022-04-20T18:41:32Z")

</div>

You can turn the loggers `Gateway.Database.Updates` and `Gateway.Database.Selects` to TRACE and you’ll see every statement we’re issuing.

---

<div class="post-metadata">

**Author:** ![kaushik.shah](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@kaushik.shah](https://forum.inductiveautomation.com/u/kaushik.shah)\
**Post date:** [April 20, 2022, 8:25pm UTC](https://forum.inductiveautomation.com/t/sql-query-monitoring/58646/3 "2022-04-20T20:25:49Z")

</div>

Awesome,

That worked great.

Just a quick ask, is it possible to filter through the Property ? I want to look for only one database connection. When I put that in filter, doesn’t seem to really work.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 20, 2022, 8:41pm UTC](https://forum.inductiveautomation.com/t/sql-query-monitoring/58646/4 "2022-04-20T20:41:22Z")

</div>

You could set a filter for the `database` MDC context key to trace for your particular DB connection name:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/b/2bc1a64d652a48c524171c752ce85cde615db0e0.png)

---

<div class="post-metadata">

**Author:** ![kaushik.shah](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@kaushik.shah](https://forum.inductiveautomation.com/u/kaushik.shah)\
**Post date:** [April 20, 2022, 9:29pm UTC](https://forum.inductiveautomation.com/t/sql-query-monitoring/58646/5 "2022-04-20T21:29:48Z")

</div>

Oops missed that.

To that, I did gave a shot but still shows up all the queries (the tag history data covers more or less the whole page and its annoying)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/6/c62b181a493ecc9f2c26d0707cd54ab01fc69a3c.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/3/8340af6646a33993987a5594fe7da0cb56e27f99.png)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 20, 2022, 9:59pm UTC](https://forum.inductiveautomation.com/t/sql-query-monitoring/58646/6 "2022-04-20T21:59:23Z")

</div>

Yes. Tag history issues a lot of queries. I’m not sure what you expected the output to be?

---

<div class="post-metadata">

**Author:** ![kaushik.shah](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@kaushik.shah](https://forum.inductiveautomation.com/u/kaushik.shah)\
**Post date:** [April 20, 2022, 10:04pm UTC](https://forum.inductiveautomation.com/t/sql-query-monitoring/58646/7 "2022-04-20T22:04:52Z")

</div>

I was hoping to print the queries related to LoMOS database.

 ![Inkedimage (1)_LI](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/0/c0c9f04756bb08aa152cb3af6e437851ac8c1dd5.jpeg)

 ![I w](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/a/2ad09d48fbed4fa87bdcd76e75cbe2de7874efc6.jpeg)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 20, 2022, 10:08pm UTC](https://forum.inductiveautomation.com/t/sql-query-monitoring/58646/8 "2022-04-20T22:08:22Z")

</div>

Oh, I see. You did reset the logging levels on the ‘Loggers’ tab? 😬  
If you did that, then I have the same assumption for the behavior here, and if that’s _not_ working then it might just be a bug.

---

<div class="post-metadata">

**Author:** ![kaushik.shah](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@kaushik.shah](https://forum.inductiveautomation.com/u/kaushik.shah)\
**Post date:** [April 20, 2022, 10:19pm UTC](https://forum.inductiveautomation.com/t/sql-query-monitoring/58646/9 "2022-04-20T22:19:16Z")

</div>

No, I didn’t but I think I know what I did wrong. When I used MDC filter, it does work. But, If I use the normal Context filter beside logger settings, that doesn’t work.  
May be that’s how it supposed to be ?
