# Slow Tag Write Performance

**URL:** <https://forum.inductiveautomation.com/t/slow-tag-write-performance/10253>\
**Category:** Ignition\
**Created:** [July 21, 2015, 11:35pm UTC](https://forum.inductiveautomation.com/t/slow-tag-write-performance/10253 "2015-07-21T23:35:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jlteel](https://avatars.discourse-cdn.com/v4/letter/j/c67d28/32.png) [@jlteel](https://forum.inductiveautomation.com/u/jlteel)\
**Post date:** [July 21, 2015, 11:35pm UTC](https://forum.inductiveautomation.com/t/slow-tag-write-performance/10253/1 "2015-07-21T23:35:12Z")

</div>

I have a script that iterates through 20 system.tag.writeAll functions, sort of like what follows. It’s only writing five values at a time, but the script takes about XX seconds to complete, which seems really excessive. Am I doing something wrong? Is there a faster way to accomplish this?

x = 0  
while x \<=19:  
val1 = somevalue  
val2 = somevalue  
val3 = somevalue  
val4 = somevalue  
val5 = somevalue

```
 tag1 = "prefix_" + str(x) + "_suffix1"
 tag2 = "prefix_" + str(x) + "_suffix2"
 tag3 = "prefix_" + str(x) + "_suffix3"
 tag4 = "prefix_" + str(x) + "_suffix4"
 tag5 = "prefix_" + str(x) + "_suffix5"

 vals = [val1,val2,val3,val4,val5]
 tags = [tag1,tag2,tag3,tag4,tag5]

 system.tag.writeAll(tags,vals)

 x = x + 1
```

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [July 22, 2015, 12:58am UTC](https://forum.inductiveautomation.com/t/slow-tag-write-performance/10253/2 "2015-07-22T00:58:14Z")

</div>

What if you called system.tag.writeAll a single time for all tags, instead of calling it 20 times?

That might be a lot faster.

---

<div class="post-metadata">

**Author:** ![jlteel](https://avatars.discourse-cdn.com/v4/letter/j/c67d28/32.png) [@jlteel](https://forum.inductiveautomation.com/u/jlteel)\
**Post date:** [July 22, 2015, 3:37am UTC](https://forum.inductiveautomation.com/t/slow-tag-write-performance/10253/3 "2015-07-22T03:37:20Z")

</div>

I’ll give it a shot. Unfortunately it means that the code will be 20 times longer to allow for all the variable assignments.

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [July 22, 2015, 5:03am UTC](https://forum.inductiveautomation.com/t/slow-tag-write-performance/10253/4 "2015-07-22T05:03:23Z")

</div>

Use a loop to create a list of all your tags, and a list of all your values. Then call system.tag.writeAll once.

---

<div class="post-metadata">

**Author:** ![jlteel](https://avatars.discourse-cdn.com/v4/letter/j/c67d28/32.png) [@jlteel](https://forum.inductiveautomation.com/u/jlteel)\
**Post date:** [July 22, 2015, 2:57pm UTC](https://forum.inductiveautomation.com/t/slow-tag-write-performance/10253/5 "2015-07-22T14:57:54Z")

</div>

I did as you suggested, and have much better results. Thanks very much for your help. I didn’t know about the list.extend() function, and that was very helpful in accomplishing this.

---

<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:** [July 23, 2015, 6:17am UTC](https://forum.inductiveautomation.com/t/slow-tag-write-performance/10253/6 "2015-07-23T06:17:28Z")

</div>

You should not need to call extend() explicitly. Try the following.

```auto
vals = []
tags = []
for x in range(20):
    val1 = somevalue
    val2 = somevalue 
    val3 = somevalue
    val4 = somevalue
    val5 = somevalue
 
    vals += [val1,val2,val3,val4,val5]
    tags += ["prefix_%d_suffix%d"%(x,i) for i in range(5)] #This creates an in place list for us, and appends it to the main list

system.tag.writeAll(tags,vals)
```
