Anything I can do to speed up this script

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.

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)

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.

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?

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

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.