This week one of our users was suffering a SQL timeout when she was trying to open a particular view or run the same in the Advanced Find. The issue was caused by a secure field that was used in the criteria of the query.
We checked the web traces to confirm the query that was forcing this timeout and get more details:
Then we look at again the actual query run by this view:
Finally we noticed that the account Tier attribute was secure and it was part of a field level security profile that our user was not part of. As soon as our user was part of this profile, she was able to run the query very quickly without issues.
Conclusion: It is better to avoid secure attributes on the criteria of our views or queries because it could bring unexpected results or even platform errors as we have seen in this article. Only use them so if you are 100% sure everyone who is going to use the view or query got access to the corresponding secure attributes by some field level security profile.
Note: This issue happens for Microsoft Dynamics 365 Customer Engagement version 220.127.116.115 (Online)