# Anything I can do to speed up this script

**URL:** <https://forum.inductiveautomation.com/t/anything-i-can-do-to-speed-up-this-script/3114>\
**Category:** Ignition\
**Created:** [July 20, 2011, 5:44pm UTC](https://forum.inductiveautomation.com/t/anything-i-can-do-to-speed-up-this-script/3114 "2011-07-20T17:44:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![diat150](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@diat150](https://forum.inductiveautomation.com/u/diat150)\
**Post date:** [July 20, 2011, 5:44pm UTC](https://forum.inductiveautomation.com/t/anything-i-can-do-to-speed-up-this-script/3114/1 "2011-07-20T17:44:19Z")

</div>

It takes about 30 seconds to gather the info in the query, then append in the 2 different sqltags for 100 different devices. I have this on a window event script\>property change.

```auto
fieldID = event.source.getComponent('Dropdown').selectedValue
query = "SELECT d.devicename, d.displayname, f.name as 'Field Name', u.name as 'Unit Name', f.foreman FROM devices d right outer join fields f on d.fieldid = f.id right outer join units u on d.unitid = u.id where f.id = %s" % fieldID
if event.propertyName in ["currentDate", "refresh"]:
	print query
	table = event.source.getComponent('Table')

	newData = []
	header = ["Displayname", "Devicename", "Field", "Unit", "Foreman", "Comm Status", "Today's Throughput"]
	
	res = system.db.runQuery(query)
	for row in res:
		tagPath = row[0]
		displayName = row[1]
		fieldName = row[2]
		unitName = row[3]
		foreman = row[4]

		tagValue = system.tag.getTagValue("%s/CommStatus" % tagPath)
		throughput = system.tag.getTagValue("%s/today_throughput" % tagPath)

		newData.append([displayName, tagPath, fieldName, unitName, foreman, tagValue, throughput])

	table.data = system.dataset.toDataSet(header, newData)
```

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [July 20, 2011, 5:50pm UTC](https://forum.inductiveautomation.com/t/anything-i-can-do-to-speed-up-this-script/3114/2 "2011-07-20T17:50:28Z")

</div>

It probably has to do with the fact that you are not subscribed (or using) the SQLTags that you are referencing in your script. If you are not using them it takes around 700ms to get the tag’s value using system.tag.getTagValue. What you need to do is put a label on the screen that is bound to an expression using all of the tags. Once you use them is some way the script will be much much faster.

---

<div class="post-metadata">

**Author:** ![diat150](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@diat150](https://forum.inductiveautomation.com/u/diat150)\
**Post date:** [July 20, 2011, 6:16pm UTC](https://forum.inductiveautomation.com/t/anything-i-can-do-to-speed-up-this-script/3114/3 "2011-07-20T18:16:24Z")

</div>

I thought that is what it was. I remember we talked about adding a new function that would call for all of the tags instead of doing it one by one. Is that still in the works?

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [July 20, 2011, 6:39pm UTC](https://forum.inductiveautomation.com/t/anything-i-can-do-to-speed-up-this-script/3114/4 "2011-07-20T18:39:22Z")

</div>

Yes, that function is still in the works. We have a ticket in but don’t know what the timeline is.

---

<div class="post-metadata">

**Author:** ![diat150](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@diat150](https://forum.inductiveautomation.com/u/diat150)\
**Post date:** [July 20, 2011, 9:35pm UTC](https://forum.inductiveautomation.com/t/anything-i-can-do-to-speed-up-this-script/3114/5 "2011-07-20T21:35:40Z")

</div>

I guess I can stick them all in a script.

Is it recommended to put hundreds or thousands of tags in an expression though?

the reason I was doing it like this is because it was more or less dynamic since I already have all of my devices in that device list.
