Business Rule Before Query to show Correct Number of Rows is slowing down performance

SimKunW
Tera Contributor

We are using a business rule Before Query to solve the incorrect row-count problem brought by security constraints.

 

However, once the rule is enabled, the performance of the whole SPM module is seriously slowed down, causing more issues like finding a demand with the same sys_id when creating a demand via portal form.

 

We wrote the business rule according to this article: 6 Ways to Eliminate 'Rows Removed by Security Constraints' Message in ServiceNow - The SN Nerd;

 

This solution is also mentioned in official KB: Before Query Business Rules - The *Other* Access Control - Support and Troubleshooting

 

What could we do to enhance performance? It seems like the script cannot be further optimized.

 

Business Rule:

SimKunW_2-1744018855401.png

 

SimKunW_1-1744018839536.png

 

Security constraint row count problem:

SimKunW_4-1744019407930.png

 

After fixed:

SimKunW_3-1744019337638.png

SimKunW_5-1744019590958.png

 

 

 

2 REPLIES 2

J Siva
Tera Sage

Hi @SimKunW 
It's expected. Please find below article which gives you more information.
https://www.servicenow.com/community/developer-articles/performance-best-practice-for-before-query-b...

 

Regards,

Siva

Ankur Bawiskar
Tera Patron
Tera Patron

@SimKunW 

Before query business rules do have performance impact on that table.

Ensure your query business rule has interactive session check

!gs.hasRole('admin') && gs.isInteractive()

Also check this link which talks about how to improve performance

Performance Best Practice for Before Query Business Rules 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader