# Good tag reading and writing practices help

**URL:** <https://forum.inductiveautomation.com/t/good-tag-reading-and-writing-practices-help/79226>\
**Category:** Ignition\
**Created:** [September 15, 2023, 4:10pm UTC](https://forum.inductiveautomation.com/t/good-tag-reading-and-writing-practices-help/79226 "2023-09-15T16:10:43Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![zacharyw.larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacharyw.larson/32/23749_2.png) [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Post date:** [September 15, 2023, 4:10pm UTC](https://forum.inductiveautomation.com/t/good-tag-reading-and-writing-practices-help/79226/1 "2023-09-15T16:10:43Z")

</div>

I have a coworker who has tag reads and writes nested in loops.

I sent him this video:  
[Strategies for Optimizing Your Ignition System Performance | Inductive Automation](https://inductiveautomation.com/resources/icc/2019/strategies-for-optimizing-your-ignition-system-performance)  
Seems to have the opposite effect of what I expected.

I tried to say like, reduce the number of tag reads and writes, they all have overhead on the gateway.  
I got back an email that the video says it is okay for up to 12,000 tags.

I also need some clarifications. My understanding is that scripts running on the Perspective pages are all being run on the gateway. That when scripts are said to be "client run scripts", this terminology is only applicable to Vision clients.  
I am pretty confident in that, so I hope I am not wrong. However, my coworker said his scripts are running in the clients, but I think he means in the sessions that still run on the gateway.

---

<div class="post-metadata">

**Author:** ![zacharyw.larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacharyw.larson/32/23749_2.png) [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Post date:** [September 18, 2023, 2:54pm UTC](https://forum.inductiveautomation.com/t/good-tag-reading-and-writing-practices-help/79226/2 "2023-09-18T14:54:58Z")

</div>

I still need help with this.

---

<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:** [September 18, 2023, 3:07pm UTC](https://forum.inductiveautomation.com/t/good-tag-reading-and-writing-practices-help/79226/3 "2023-09-18T15:07:35Z")

</div>

Did you show them this:

> [@Editing historian tag data](https://forum.inductiveautomation.com/t/editing-historian-tag-data/49328/32):
>
> Throw this into your script console and run it. from java.lang import System tagPaths = [] ret = 0 currentTime = system.date.now() for i in range(400): tagPaths.append('[Client]CurrentTime') start = System.nanoTime() for i in range(400): ret = system.tag.readBlocking(tagPaths[i]) end = System.nanoTime() print '400 singular reads took %.3f ms' % ((end-start) / 1000000.0) values = [] paths = [] start = System.nanoTime() for i in range(400): values.append(currentTime) paths.append…

---

<div class="post-metadata">

**Author:** ![zacharyw.larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacharyw.larson/32/23749_2.png) [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Post date:** [September 18, 2023, 3:26pm UTC](https://forum.inductiveautomation.com/t/good-tag-reading-and-writing-practices-help/79226/4 "2023-09-18T15:26:10Z")

</div>

Yes, I did. And thanks again.  
I also keep it printed out next to me.

---

<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:** [September 18, 2023, 3:28pm UTC](https://forum.inductiveautomation.com/t/good-tag-reading-and-writing-practices-help/79226/5 "2023-09-18T15:28:05Z")

</div>

In perspective, **everything** runs in the gateway.

Here is a link (with other links as well) for reference:

> [@Best way to convert a vision mobile app to perspective](https://forum.inductiveautomation.com/t/best-way-to-convert-a-vision-mobile-app-to-perspective/78683/4):
>
> A few links (there are other links posted in these which are also very applicable): IMHO, the biggest hurdles to wrapping your head around perspective (in no particular order) are: Layout management (e.g. when to use which kind of container) Styles are really, really powerful use them! Embedded views are great but use them sparingly. EVERYTHING executes in the gateway. EVERY-THING!! So if it doesn't say available in gateway or perspective scope, don't even try it. The script console will …

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [September 18, 2023, 5:33pm UTC](https://forum.inductiveautomation.com/t/good-tag-reading-and-writing-practices-help/79226/6 "2023-09-18T17:33:48Z")

</div>

> [@zacharyw.larson](#):
>
> I got back an email that the video says it is okay for up to 12,000 tags.

The same video also says that between single reads and all reads, always choose all reads.

---

<div class="post-metadata">

**Author:** ![zacharyw.larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacharyw.larson/32/23749_2.png) [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Post date:** [September 18, 2023, 5:46pm UTC](https://forum.inductiveautomation.com/t/good-tag-reading-and-writing-practices-help/79226/7 "2023-09-18T17:46:01Z")

</div>

Sometimes I think that I have this stuff very well understood.  
Then I hear something so contradictory, that I have to question everything.

---

<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 18, 2023, 6:06pm UTC](https://forum.inductiveautomation.com/t/good-tag-reading-and-writing-practices-help/79226/8 "2023-09-18T18:06:58Z")

</div>

I did not watch that video as it's quite long, but they may have meant "client run scripts" in regards to perspective as in a client/user triggers the script to run via a button press in a view, but you're still correct in that all scripts in perspective run on the gateway.

What do you think has been contradictory? I think what everyone is saying here is what you already know or suspect - everything runs on the gateway in perspective, and that `system.tag.readBlocking(['all','your','tags','in','one','go'])` is better than doing a call per tag.

---

<div class="post-metadata">

**Author:** ![zacharyw.larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacharyw.larson/32/23749_2.png) [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Post date:** [September 18, 2023, 6:17pm UTC](https://forum.inductiveautomation.com/t/good-tag-reading-and-writing-practices-help/79226/9 "2023-09-18T18:17:51Z")

</div>

Who meant Client run scripts when?

If you mean my coworker, I think he meant that he didn't think the script ran on the gateway.

My coworker watched that video, and then came back with some understanding that was contradictory to mine.  
It was so different, I had to question what I knew.  
I tried to say some of that in the first post.

In the video, I am not sure what an all reads is.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [September 18, 2023, 6:28pm UTC](https://forum.inductiveautomation.com/t/good-tag-reading-and-writing-practices-help/79226/10 "2023-09-18T18:28:16Z")

</div>

> [@zacharyw.larson](#):
>
> I am not sure what an all reads is.

In v7 there was system.tag.read() and system.tag.readAll(). readBlocking() replaced those.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [September 18, 2023, 6:33pm UTC](https://forum.inductiveautomation.com/t/good-tag-reading-and-writing-practices-help/79226/11 "2023-09-18T18:33:09Z")

</div>

Sorry, meant to say that from the bits and pieces I've seen (I haven't fully watched it either), it seems @Kyle_Chase was referencing vision clients. So, I just pinged him in this post to see if he can clarify.(Thanks Kyle, I'll watch it all the way through... really!)

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [September 18, 2023, 6:37pm UTC](https://forum.inductiveautomation.com/t/good-tag-reading-and-writing-practices-help/79226/12 "2023-09-18T18:37:50Z")

</div>

Oh. And you have my permission to tell him, "Jordan wants to know why you're deliberatly writing inefficient code". 😉

---

<div class="post-metadata">

**Author:** ![zacharyw.larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacharyw.larson/32/23749_2.png) [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Post date:** [September 18, 2023, 6:38pm UTC](https://forum.inductiveautomation.com/t/good-tag-reading-and-writing-practices-help/79226/13 "2023-09-18T18:38:53Z")

</div>

Him Kyle, or him me?  
If I write inefficient code, I don't know the better way.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [September 18, 2023, 6:40pm UTC](https://forum.inductiveautomation.com/t/good-tag-reading-and-writing-practices-help/79226/14 "2023-09-18T18:40:00Z")

</div>

Him, as in Zachary-asking-his-co-worker.

---

<div class="post-metadata">

**Author:** ![Kyle\_Chase](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@Kyle\_Chase](https://forum.inductiveautomation.com/u/Kyle_Chase)\
**Post date:** [October 3, 2023, 4:45pm UTC](https://forum.inductiveautomation.com/t/good-tag-reading-and-writing-practices-help/79226/15 "2023-10-03T16:45:47Z")

</div>

You want to minimize the number of system.tag.readBlocking calls. The number of tags has a minimal impact on performance. In perspective, the client session exists on the gateway. This will minimize the impact of multiple readBlocking calls, because there is no network latency between the client session and the gateway. There is a balance between writing understandable code and performant code, you will have to judge where to draw this line for your application.
