Platform performance · LessonBy Praveen T, ServiceNow Trainer, 9 yrs · Published · ServiceNow · all levels
Query performance and indexes
Find slow queries, read the slow log, and add indexes that actually help.
Quick answer
Find slow queries, read the slow log, and add indexes that actually help.
Key takeaways
- Start from the slow query log, not from guesses
- Date boundaries are the cheapest optimisation available
- Composite index order must match the query
- Every index costs something on insert and update
Where slow queries show up
Slow list loads, slow forms and long running jobs usually trace to one query. Start with System Diagnostics slow queries, then look at the transaction log for the same table and time window.
What makes a query slow
Three causes cover most cases: no index on the field being filtered, a query on a large table with no date boundary, and dot-walking or ORs that prevent index use. Sorting on an unindexed field is a close fourth.
Adding indexes properly
Indexes speed reads and cost writes.
- Index fields used in frequent filters and sorts, not every field
- Composite indexes must match the query order to be used
- Test on a cloned instance with production volume, not on an empty dev
- Ask ServiceNow support to review index changes on very large tables
Practice challenge
+0 XPStreak ×0
Question 1 of 2
Which is the cheapest first fix for a slow list?
Frequently asked questions
Should we index every filtered field?
No. Index the fields that appear in frequent, selective filters. Over indexing slows writes and inflates storage.
Why did a query get slow suddenly?
Usually data growth crossed a threshold, or a filter changed so an index no longer applies. Compare the query plan before and after.