Find out Which Business Rule is Slow

Community Alums
Not applicable

Problem

I did a Full load of data into the core_company table.  About 170K records.  It ran for over 2 days at about 50 inserts per minute.  I thought the problem was a slow Business Rule.  I could not turn off the Business Rules - I thought it too risky.   There are 48 Business rules on the core_company table.


Solution
I wrote a script to add timing code to the Business Rules.  The Script Include contains EXAMPLES (see description field in the script include) which explain how to run the code. The code has three main capabilities: 

 

  1. Method to add Timing Code ot each Business Rule. (can be run a Background - Script).
  2. Method to remove timing code from each Business Rule.  (can be run a Background - Script).
  3. Method to execute an Insert (on any table) - and log the timing results to the sys_log.

 

see Attached Update Set. 

If anyone knows of a better way to do this - then please reply to this Question.  Otherwise, this Question is really just a way of sharing stuff (since I can't write Articles).

System Property

ServiceNow Supprot told me:
There is the glide.businessrule.callstack system property that logs any business rule that runs on the instance in the node logs. This could be used but since it logs ALL business rules running in the instance it could potentially cause some performance issues if left running for long periods of time.

In regards to performance in general production and subproduction instances do not have the same exact configurations, jobs running, transactions happening so it is not fair to expect production and subproduction to have the same speeds as they are not being used exactly the same. At the same time, your team could request an instance assessment to determine if adding more nodes would be reasonable here in regards to overall instance health.

I suggest considering enabling the system property above if your team wants to try and find which business rules are running and when they are finishing or adding some logging statement that would show when BR starts/finishes.

1 ACCEPTED SOLUTION

Tai Vu
Kilo Patron
Kilo Patron

Hi @Community Alums 

Monitoring a transaction can be done in a couple of ways:

  1. Debug Business Rule: Enable debug business rule and execute your database action. This will display all business rules and their execution times in the Session Log tab.

  2. Node Log File Browser: Identify your Session ID associated with the slow database action. Use System Logs > Utilities > Node Log File Browser to view any system log entries, including business rules and their execution times.

 

Cheers,

Tai Vu

View solution in original post

1 REPLY 1

Tai Vu
Kilo Patron
Kilo Patron

Hi @Community Alums 

Monitoring a transaction can be done in a couple of ways:

  1. Debug Business Rule: Enable debug business rule and execute your database action. This will display all business rules and their execution times in the Session Log tab.

  2. Node Log File Browser: Identify your Session ID associated with the slow database action. Use System Logs > Utilities > Node Log File Browser to view any system log entries, including business rules and their execution times.

 

Cheers,

Tai Vu