# Need help with Query Optimization Tool

**URL:** <https://forum.inductiveautomation.com/t/need-help-with-query-optimization-tool/116959>\
**Category:** Ignition\
**Tags:** namedqueries, scripting, ignition81, perspective\
**Created:** [September 1, 2026, 12:40pm UTC](https://forum.inductiveautomation.com/t/need-help-with-query-optimization-tool/116959 "2026-09-01T12:40:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ruchika](https://avatars.discourse-cdn.com/v4/letter/r/dbc845/32.png) [@Ruchika](https://forum.inductiveautomation.com/u/Ruchika)\
**Post date:** [September 1, 2026, 12:40pm UTC](https://forum.inductiveautomation.com/t/need-help-with-query-optimization-tool/116959/1 "2026-09-01T12:40:41Z")

</div>

I want to create a separate tool in Ignition Perspective for sql query optimization. This tool should show list of queries, time taken by them, whether it is slow/moderate and how it can be improved as well. Is it something possible ?

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [September 1, 2026, 3:04pm UTC](https://forum.inductiveautomation.com/t/need-help-with-query-optimization-tool/116959/2 "2026-09-01T15:04:24Z")

</div>

Any such tool would need to look at the execution plan of the query to determine how the query is planned to run, and if there are any slow things identified like full table scans

---

<div class="post-metadata">

**Author:** ![lane.duncan](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lane.duncan/32/83700_2.png) [@lane.duncan](https://forum.inductiveautomation.com/u/lane.duncan)\
**Post date:** [September 2, 2026, 5:42am UTC](https://forum.inductiveautomation.com/t/need-help-with-query-optimization-tool/116959/3 "2026-09-02T05:42:06Z")

</div>

The official recommendation is to remove Ignition from the picture and test queries directly with the database management software, as slow queries are normally a database issue, not an Ignition issue:

> **[Slow Queries | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.3/platform/sql-in-ignition/basic-sql-troubleshooting/slow-queries)**
>
> Slow running queries can be a big problem. Not only can data take a long time to display on the screen, but it can end up slowing down the whole client or session. This page covers checks and adjustments you can make when your project has a slow...

That being said, a “Query Execution Analysis” test tool would be an interesting project.

Looking at named queries only, I suppose you could (1) get a list of queries by listing the files in the directory, then (2) you could inspect the files and try to determine the parameters required, then (3) a script could be generated to test and time all the queries.

This sounds like a lot of work that will produce mediocre results at best.

Maybe this is a good task for an AI agent. You could start with logging all the queries and feeding the log to the agent, and have it write the results to a db table, which can the be displayed in Ignition.

> [@SQL Query Monitoring](https://forum.inductiveautomation.com/t/sql-query-monitoring/58646):
>
> 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 ?

Sounds like fun. Good luck.

---

<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:** [September 2, 2026, 4:13pm UTC](https://forum.inductiveautomation.com/t/need-help-with-query-optimization-tool/116959/4 "2026-09-02T16:13:33Z")

</div>

If this is for fun and a learning project I say go for it there's a lot of things you can touch on and learn - gathering what queries are being run by ignition, parsing the logs etc. Ignition already logs slow queries and I have a script to fetch them from a while ago.

> [@Log filter for slow queries?](https://forum.inductiveautomation.com/t/log-filter-for-slow-queries/53537/8):
>
> Ok great I have it working well enough now so that I can revisit the queries and see some specifics. For anyone wondering how to do the same thing, this is a function I call from a gateway message handler: """ These scripts can ONLY be run on the gateway context. """ from com.inductiveautomation.ignition.gateway import IgnitionGateway import system.util logger = system.util.getLogger("gateway.query") LIMIT = 100 def getLongQueries(): """ Note: query.duration is a long, measuring millisec…

If this is for production I might say to not bother. Find the slow queries that Ignition logs, use your database software of choice to analyze the query and dissect from there. Theres not much more to it in my experience and I don't know what value add Ignition will do for you here outside of maybe curating slow queries into a db / email for you or a DBA on a regular basis which could admittedly be helpful.
