OBLYTECH Logo
OBLYTECH Logo

Cache and Index Tuning

A database index in ServiceNow helps queries access table data, but its value depends on the query and the fields selected. Start with a slow query, evaluate an index suggestion, test it outside production, and measure the result. Keep an index because it improves the workload, rather than because creation succeeded.

Database index changes start with a measured slow query

Choose a specific slow query before deciding which index to create. Record the table, the conditions used by the affected transaction, and the execution metrics available for that query. This gives the change a defined purpose: improving an identifiable access pattern rather than adding an index to a table because the table seems busy.

The Index Suggestion Engine, or ISE, analyzes a selected slow query and information from its tables. Its recommendations depend on query metrics and column statistics. A suggestion therefore needs interpretation alongside the workload that prompted it. Treat the query record as the starting point for the investigation and the proposed index as a candidate to evaluate.

For the surrounding investigation, use the guidance on slow queries, indexing, and GlideRecord performance. Keep this index change focused on the query you can measure. If several symptoms appear together, identify which transaction produced the slow-query evidence before making a database change.

Check the workflow against your instance and release. The Index Suggestion Engine (ISE) supports MySQL databases only, and the Index Suggestion Engine plugin, com.glide.index_suggestion, is activated by default in new and upgraded instances. Those details do not establish that a particular recommendation will improve your query.

Generate a suggestion with enough evidence

Generating an index suggestion requires the admin role. Navigate to All > System Diagnostics > Stats > Slow Queries, open the query record, and select Suggest Index. If the engine needs additional information, resolve the messages it displays before interpreting the absence of a recommendation as a reason to design an index manually.

  1. If the query metrics are outdated, use the message’s link to obtain recent metrics, then select Suggest Index again.
  2. If column statistics are missing, schedule the Collect Column Stats job. You can use the default quieter time or collect the statistics immediately.
  3. After scheduled collection finishes, return to the Slow Queries record and select Suggest Index. For immediate collection, wait for the Collect Column Statistics progress indicator before requesting the suggestion again.
  4. When generation succeeds, inspect the Index Suggestion record with its State set to Suggested.

The statistics gathered for analysis include cardinality and null counts. This helps explain why a proposed field list should be assessed with actual table information. A field’s business importance alone does not establish how helpful it will be in an index.

A suggestion can also be unavailable because the engine cannot recommend an index for that query. Preserve the explanation in the investigation record. Repeated requests do not supply missing data.

Test the suggestion before production creation

Exporting a suggestion to a non-production instance requires the admin role. This separates review of the proposed index from the decision to create it in production. The export transfers an index suggestion for creation and evaluation; plan a test that represents the transaction whose performance matters.

  1. In production, navigate to System Diagnostics > Index Suggestions > Index Suggestions > To review.
  2. Open the suggestion by selecting its table in the Table Name column, then select Export.
  3. In the non-production instance, open the same To review view and select Import Suggestions under Related Links.
  4. Choose the exported XML file in the Import XML form and select Upload.
  5. Locate the imported suggestion, then continue with scheduling creation and testing index performance.

For the test plan, document the conditions under which you collected the baseline and repeat those conditions after creation. Record differences in the test data and workload so that an apparent improvement is not credited to the index without examination. This is a comparison plan, not a promise that a smaller environment predicts production performance.

Before approving production work, connect the test evidence to the change risk assessment. Specify the intended query improvement, the observation period, and the action to take if the index is unused or performance becomes worse.

For help planning this work, see ServiceNow implementation.

Create a table index with deliberate field choices

Creating a table index requires the admin role. One route is All > System Definition > Tables & Columns: select the table label and navigate to the Index creator. Another route is All > System Definition > Tables: select the table, open the Database Indexes related list, and select New.

Select the fields for the index deliberately. Selection order affects how the index works, so preserve the reviewed order in the change record. Index design requires database architecture expertise; involve a database administrator when that expertise is unavailable within the team making the change.

Select Unique Index when a unique index is intended, then use Create Index. The Table Name field is a reference field in this process; overriding its default does not change the target. Review the selected table and fields before proceeding rather than relying on that field to redirect creation.

The available index types include btree, the default, and Columnstore (RaptorDB Pro), available with RaptorDB Professional. Columnstore uses compressed, column-oriented storage and can improve retrieval for large datasets. Do not treat the presence of an index type as sufficient reason to choose it over the design reviewed for the query.

Creating an index on a large table can affect system performance. Plan such creation for off-peak hours, and avoid overlapping a CMDB index build with a discovery job. Include the expected operational activity in the scheduling decision, alongside the proposed index definition.

Evaluate the index beyond successful creation

For an index created through the suggestion workflow, the ISE evaluates effectiveness over 14 days and performs an hourly evaluation during that period. Evaluating Effectiveness means assessment is underway. It does not mean that the index has already demonstrated a lasting improvement.

Follow the record through Index Suggestions > To review, Index Suggestions > In Progress, and Index Suggestions > Done. Keep the state distinct from the performance evidence. Creation Scheduled records a planned action; Creation in Progress records execution; Creation Failed records a failure that needs investigation.

After the evaluation period, Created indicates that the ISE determined the index improved query performance and the database continues using it. Drop Suggested—Unused indicates that the database is not using it for the slow query. Drop Suggested—Performance Degradation identifies a recommendation to remove an index that did not improve query time or worsened performance.

Keep the query measurements and the final decision together. A wider review of performance tuning and upgrades can help frame the next investigation when the measured transaction still fails its operational requirement. Hold off on another index until the evidence shows what is still slow.

Remove an index through the appropriate workflow

Dropping a slow-query index requires the admin role. Open All > System Diagnostics > Index Suggestions > Index Suggestions > In Progress, select the table associated with the suggestion, and select Schedule Drop. In Schedule Index Drop, select the intended time and select Drop.

A scheduled removal changes the state to Drop Scheduled. Verify Dropped after completion, either on the record or in System Diagnostics > Index Suggestions > Index Suggestions > Done. Allow for removal to take an hour or longer on large tables such as Incident or CMDB, rather than assuming it finishes immediately.

For a custom index, the admin role is also required. Navigate to All > System Definition > Tables, open the table, and select Database Indexes. Open the custom index and select Drop on the Database Indexes form. Record the exact index selected so the removal can be reviewed against the approved change.

Index decisions and records answer the questions that come up most

Can I keep an index the engine recommends dropping?

The Accept option retains it despite the recommendation. Obtain Customer Service and Support guidance before using that option. Record the reason for retaining it alongside the recommendation so the exception has an accountable decision.

What does Superseded mean on an index suggestion?

A newer suggestion replaced the index for the same table and slow query. Review the newer suggestion before acting on the older record, and keep the relationship visible in the investigation notes.

How can I distinguish exported suggestion files?

The downloaded file name begins with sys_index_suggestion_ and includes an alphanumeric identifier before the XML extension. Preserve that identifier when recording which suggestion was imported into the test instance.

What should I do if the drop fails?

Drop Failed indicates that the ISE could not remove the index. Contact Customer Service and Support for assistance, and retain the failed record as part of the change evidence.