More efficient relevance

The following relevance gets me computers that have a specific value for the _ServerResponsibilityGroup property, but seems to take a real long time. Is there a way to make this relevance more efficient?

number of bes computers whose (exist property results whose (name of property of it as lowercase = "_ServerResponsibilityGroup" as lowercase AND value of it as lowercase contains "abc") of it)

Thanks,
Bob_K

Yes, there are!

For the authoritative explanation I’d point to Efficient Session Relevance Query for Computer Properties

Brolly33 has a good description of “why” a query like this is slow. As written, you are looping through every BES Computer, and then for each BES Computer you are performing a lookup for every property result, and then for each property result you are filtering for the name of the property and the value of the result.

If it takes 1 second to find the right property, and you have a thousand computers, you’ll spend a thousand seconds repeatedly finding that property (it shouldn’t really take that long, but illustrates what I mean)

If you just need the count, you could perform the property lookup once, and retrieve, filter, and count the results via

number of results whose (value of it as lowercase contains "abc") of bes properties whose (name of it as lowercase = "_ServerResponsibilityGroup" as lowercase

This executes one loop through the ‘BES Properties’ to filter to the property with the right name, then counts only the results of this one property.

If you need more than the count - like the actual computer - you could refactor that to something like

(id of computer of it, name of computer of it | "Not Reported", values of it) of results whose (value of it as lowercase contains "abc") of bes properties whose (name of it as lowercase = "_ServerResponsibilityGroup" as lowercase

The post I linked has some great guidance in case you need to retrieve more than one property from each computer - how to ensure your property lookups only happen once, regardless of how many computers you need to loop through.

4 Likes