Soumitra Dutta : How do I optimize queries and scripts for USA instances?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hello,
Soumitra Dutta here, I’m looking for ways to optimize queries and scripts on our USA ServiceNow instance. For those who’ve handled performance tuning before, what steps or best practices would you recommend? I’d really appreciate your suggestions.
Regards,
Soumitra Dutta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Hello @soumitrardutta ,
As per my understanding , i follow some practices that i mention below :
1)Identify slow areas first
Check Slow Queries and Transaction Logs
Example: If a report shows high execution time, optimize its query first
2)Always filter GlideRecord queries
Avoid querying full tables
Example:
gr.addQuery('active', true);gr.setLimit(1);This is faster than querying all records
3)Use indexed fields
Prefer fields like sys_id, number, user_name
Avoid searching on non-indexed text fields
4)Limit returned data
Use setLimit() when only one or few records are needed
Reduces memory and DB load
5)Optimize Business Rules
Add conditions so rules don’t run unnecessarily
Example: Run only when state changes
Use Async Business Rules for heavy processing
6)Avoid heavy logic in After Business Rules
Move logic to Scheduled Jobs, Flows, or Async rules
- Keeps form save fast for users
7)Keep client-side scripts light
Avoid heavy logic in onLoad
Reduce multiple GlideAjax calls
Never use GlideRecord on client side
8)Use Script Includes for reuse
Centralize logic instead of repeating code
Cache data if the same logic runs frequently
You can also refer this following articles for better tunning :
https://www.servicenow.com/community/queensland-snug/coding-best-practices/ba-p/2273791
https://www.servicenow.com/community/queensland-snug/server-script-best-practices/ba-p/2273782
https://www.servicenow.com/community/queensland-snug/client-script-best-practices/ba-p/2273951
If this helps you then mark it as helpful and accept as solution.
Regards,
Aditya,
Technical Consultant
