# Value changed script delay

**URL:** <https://forum.inductiveautomation.com/t/value-changed-script-delay/84942>\
**Category:** Ignition\
**Created:** [January 30, 2024, 9:10am UTC](https://forum.inductiveautomation.com/t/value-changed-script-delay/84942 "2024-01-30T09:10:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alpar\_Kovacs](https://avatars.discourse-cdn.com/v4/letter/a/838e76/32.png) [@Alpar\_Kovacs](https://forum.inductiveautomation.com/u/Alpar_Kovacs)\
**Post date:** [January 30, 2024, 9:10am UTC](https://forum.inductiveautomation.com/t/value-changed-script-delay/84942/1 "2024-01-30T09:10:51Z")

</div>

Hello,

I'm facing with a strange behave and I have no idea how to identify the cause.  
-- Ignition 8.1.35 with 6GB RAM allocated (8GB total) and 4 CPU 2.97 GHz in virtual environment --

on some OPC tags value changed scripts are in place that are inserting the tag value in an SQL  
the problem is that from the moment when the value are changing (I can see it the tag Timestamp parameter) and the moment when the script are executed we can see a delay of 2-5 minutes and obviously in this time the value can change multiple times and we are losing data

on the status page I see Clock drift events recorded in every 1-3 hours but the delay is happen constantly

can anybody give some ideas how to catch the cause of this issue?

thank you.

 ![Ignition Gateway](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/7/777f06a278f0641c68758d13b41cf4614b278f07.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:** [January 30, 2024, 1:34pm UTC](https://forum.inductiveautomation.com/t/value-changed-script-delay/84942/2 "2024-01-30T13:34:36Z")

</div>

> [@Alpar\_Kovacs](#):
>
> that are inserting the tag value in an SQL

This is a task that takes too long to do directly in a tag event. Use the store and forward engine or use a gateway tag change event (in the project, not on the tag). See this recent topic for **why** this is true:

> [@Tag Change Scripts stop working](https://forum.inductiveautomation.com/t/tag-change-scripts-stop-working/84819):
>
> Every once in a while, we have a situation where basically all of our tag change scripts stop processing. I finally saw this error in the Console of the designer Diagnostics. It's almost as if the Basic Execution Engine has run out of threads. WARN Common.BasicExecutionEngine - Execution rejected... running in calling thread [AWT-EventQueue-0] immediately. [com.inductiveautomation.ignition.designer.tags.tree.TagTreeModelImpl$BatchOp$$Lambda$949/0x0000016597b1a668@d72dc75] Any ideas where I can…

If you have very dynamic requirements, such that the event must **originate** on a tag event, this topic of _ **advanced** _ techniques might help you:

> [@Java concurrent queue for tag change scripts](https://forum.inductiveautomation.com/t/java-concurrent-queue-for-tag-change-scripts/82044):
>
> Continuing the discussion from [[SOLVED] Are tag Value Changed scripts running asynchronously?](https://forum.inductiveautomation.com/t/solved-are-tag-value-changed-scripts-running-asynchronously/68704/5): We've got code in our standard library that I need to log a value change on a tag and then associate various data points with that value change. The value is located in a UDT, and because this is part of our "standard" library we use for our customers, the number of tags is variable and quite possibly numerous so having a gateway tag event script isn't feasible for this solution. I was reading up on …

---

<div class="post-metadata">

**Author:** ![Alpar\_Kovacs](https://avatars.discourse-cdn.com/v4/letter/a/838e76/32.png) [@Alpar\_Kovacs](https://forum.inductiveautomation.com/u/Alpar_Kovacs)\
**Post date:** [January 30, 2024, 3:12pm UTC](https://forum.inductiveautomation.com/t/value-changed-script-delay/84942/3 "2024-01-30T15:12:08Z")

</div>

> [@pturmel](#):
>
> This is a task that takes too long to do directly in a tag event. Use the store and forward engine or use a gateway tag change event (in the project, not on the tag). See this recent topic for **why** this is true:

sorry but I'm confused a bit . As far as I know the store and forward are enabled for all data connections. What I need to do additionaly?

---

<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:** [January 30, 2024, 3:28pm UTC](https://forum.inductiveautomation.com/t/value-changed-script-delay/84942/4 "2024-01-30T15:28:14Z")

</div>

Scripted database operations do not use the store and forward engine unless the script function has "SF" in its name, and naturally that only applies to updates. (The store and forward engine can't do queries.)

[https://docs.inductiveautomation.com/display/DOC81/system.db](https://docs.inductiveautomation.com/display/DOC81/system.db)

---

<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:** [January 30, 2024, 3:29pm UTC](https://forum.inductiveautomation.com/t/value-changed-script-delay/84942/5 "2024-01-30T15:29:20Z")

</div>

> [@Alpar\_Kovacs](#):
>
> store and forward are enabled for all data connections

Enabled, but only **used** by default by the historian, and by transaction groups. And the latter can be configured to bypass the S&F subsystem.

---

<div class="post-metadata">

**Author:** ![Alpar\_Kovacs](https://avatars.discourse-cdn.com/v4/letter/a/838e76/32.png) [@Alpar\_Kovacs](https://forum.inductiveautomation.com/u/Alpar_Kovacs)\
**Post date:** [January 31, 2024, 10:54am UTC](https://forum.inductiveautomation.com/t/value-changed-script-delay/84942/6 "2024-01-31T10:54:53Z")

</div>

is there a way to see what scripts ar more resource consuming?

---

<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:** [January 31, 2024, 1:15pm UTC](https://forum.inductiveautomation.com/t/value-changed-script-delay/84942/7 "2024-01-31T13:15:19Z")

</div>

As noted in those other topics, using java's `System.nanoTime()` to obtain timing information in your scripts will help you identify the problems. But I'd first just search for `system.db.`, `system.tag.`, `system.opc.`, and `system.net.` in your tag scripts. That will quickly highlight likely problems.
