# Query executer in logs

**URL:** <https://forum.inductiveautomation.com/t/query-executer-in-logs/81110>\
**Category:** Ignition\
**Tags:** ignition81, vision\
**Created:** [October 27, 2023, 5:19pm UTC](https://forum.inductiveautomation.com/t/query-executer-in-logs/81110 "2023-10-27T17:19:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Esmeralda\_Lopez1](https://avatars.discourse-cdn.com/v4/letter/e/cdc98d/32.png) [@Esmeralda\_Lopez1](https://forum.inductiveautomation.com/u/Esmeralda_Lopez1)\
**Post date:** [October 27, 2023, 5:19pm UTC](https://forum.inductiveautomation.com/t/query-executer-in-logs/81110/1 "2023-10-27T17:19:49Z")

</div>

Hello everyone!

I found this error in a log, the console told me that is saving everything at one file but I found this too in the diagnostics window, says the same.

[NonResponsiveEdt-2023-10-26\_002939.json](https://forum.inductiveautomation.com/uploads/short-url/57o3JEVHFg6ZmgeanuUaMVeBXlP.json) (136.6 KB)

Do you think that is a query? Both says in the status : WAITING

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/8/a8c5294b7b9defe92612e3d2021b114c9852dc6f.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/5/65f0bb0a15b8b407472806bdf961808be190eb4c.png)

---

<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:** [October 27, 2023, 5:46pm UTC](https://forum.inductiveautomation.com/t/query-executer-in-logs/81110/2 "2023-10-27T17:46:11Z")

</div>

Yes, that would be you running an long query from a foreground script (event script, runScript() expression function, et cetera). Don't do that--it locks up the UI.

Use named query bindings. Those run the query in the background safely. Or you can learn to use `invokeAsynchronous`, but many people do not have the discipline to avoid interacting with UI components from the background, which has its own crash risks.

---

<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:** [October 27, 2023, 5:59pm UTC](https://forum.inductiveautomation.com/t/query-executer-in-logs/81110/3 "2023-10-27T17:59:07Z")

</div>

> [@pturmel](#):
>
> Yes, that would be you running an long query from a foreground script (event script, runScript() expression function, et cetera)

In the case of this particular thread dump, it's a button's `actionPerformed` event. But the main point stands.

---

<div class="post-metadata">

**Author:** ![Esmeralda\_Lopez1](https://avatars.discourse-cdn.com/v4/letter/e/cdc98d/32.png) [@Esmeralda\_Lopez1](https://forum.inductiveautomation.com/u/Esmeralda_Lopez1)\
**Post date:** [October 27, 2023, 6:17pm UTC](https://forum.inductiveautomation.com/t/query-executer-in-logs/81110/4 "2023-10-27T18:17:26Z")

</div>

By calling in a button or textfield as runnamedquery function that I have created in the part of the named queries . Will be a foreground script? or it is fine use like that?

---

<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:** [October 27, 2023, 6:23pm UTC](https://forum.inductiveautomation.com/t/query-executer-in-logs/81110/5 "2023-10-27T18:23:46Z")

</div>

It is not fine. If a script calls a named query, the NQ runs in the script environment. Only a NQ **binding** runs in the background by default.

It is reasonable for a button's actionPerformed event to run a small **UPDATE** or **INSERT** query to apply a user's changes to the DB.

But that event script should **NOT** run the follow-up query to obtain fresh data to **display**. The script should use `system.db.refresh()` to cause a non-polling NQ binding to re-execute to get the fresh display data. Or, if the query is too complex or varied to be run from a binding, then `system.util.invokeAsynchronous()` should be used to run a separate function for all of that. (But obey the rules for setting the results back into the UI.)
