(imported comment written by BenKus)
Hey npeters,
Optimization of session queries is a very advanced topic… but I think it is a lot of fun…
Your expression is the most straight-forward way to write the relevance for this task, but I believe the reason it is slower than you want is that under the covers of the relevance expression, the engine is looking through all Fixlets to see which ones are relevant and it does this for all the computers. So if you have 1000 computers and 4000 Fixlets, it needs to do 4,000,000 operations, which takes it some time to complete.
To make it run faster, we can be a little creative… we might try to look at the problem the other way around and start with Fixlets and try to get the applicable computers from the Fixlets… you might think that this has the same problem as the last expression (needing to iterate through all computers for each Fixlets), but for efficiency, the underlying engine knows how to directly look up applicable computers for each Fixlet.
Try this:
number of unique values of names of applicable computers of bes fixlets whose (source of it as lowercase = “microsoft” AND source severity of it as lowercase = “critical” )
or if you are using BES 7.0, you can use “sets” (sets only store one unique value per set so you don’t have to explicitly get the unique values)…
number of elements of sets of applicable computers of bes fixlets whose (source of it as lowercase = “microsoft” AND source severity of it as lowercase = “critical” )
But actually, I think you wanted the computers that didn’t have a relevant critical Fixlet, which you can get like this:
number of bes computers - number of unique values of names of applicable computers of bes fixlets whose (source of it as lowercase = “microsoft” AND source severity of it as lowercase = “critical” )
On my example (small) deployment, these new expressions run much faster (roughly 7x) than the original expression you started with… Can you let us know your results?
Ben