Skip to page contentSkip to chat
ServiceNow support
    • Community
      Ask questions, give advice, and connect with fellow ServiceNow professionals.
      Developer
      Build, test, and deploy applications
      Documentation
      Find detailed information about ServiceNow products, apps, features, and releases.
      Impact
      Accelerate ROI and amplify your expertise.
      Learning
      Build skills with instructor-led and online training.
      Partner
      Grow your business with promotions, news, and marketing tools
      ServiceNow
      Learn about ServiceNow products & solutions.
      Store
      Download certified apps and integrations that complement ServiceNow.
      Support
      Manage your instances, access self-help, and get technical support.
"SC Popular Items" sc-popular-items widget causes excessive queries - Known Error
  • >
  • Knowledge Base
  • >
  • Known Error (Knowledge Base)
  • >
  • "SC Popular Items" sc-popular-items widget causes excessive queries
KB0821439

"SC Popular Items" sc-popular-items widget causes excessive queries


2605 Views Last updated : Dec 21, 2024 public Copy Permalink
KB Summary by Now Assist

Description

The OOB "sc-popular-items" widget relies on an aggregate query of the live sc_req_item table, with the code like the following:

var count = new GlideAggregate('sc_req_item');
count.addAggregate('COUNT','cat_item');
count.groupBy('cat_item');
count.addQuery('cat_item.sys_class_name', 'NOT IN', 'sc_cat_item_guide,sc_cat_item_wizard,sc_cat_item_content');
count.addQuery('cat_item.sc_catalogs', 'IN', data.sc_catalog);
count.orderByAggregate('COUNT', 'cat_item');
count.query();
while (count.next() && items.length < data.TopItemslimit) {
if (!$sp.canReadRecord("sc_cat_item", count.cat_item.sys_id.getDisplayValue()))
continue; // user does not have permission to see this item
var item = {};
item.count = count.getAggregate('COUNT', 'cat_item');
item.name = count.cat_item.name.getDisplayValue();
item.sys_id = count.cat_item.sys_id.getDisplayValue();
items.push(item);
}

This runs every time someone loads or reloads a page that contains the "sc-popular-items" widget. For large scale Service Catalogs this query can become very impactful on the database. A re-design is suggested in the article Speed up the "SC Popular Items" Service Portal Widget by using a snapshot possibly resulting in a much faster user experience and reduction of overall load on the database.

Another hypothetical solution would be to leverage the Platform Analytics application to store aggregate trend data to use as the source of the widget.

Steps to Reproduce

1. Clone the out-of-the-box widget "SC Popular Items" widget.
2. Use the widget in a Service Portal page that is frequently accessed.
3. Have enough tasks and sc_req_item records in the system to make the queries slow.

Workaround

This problem is under review and targeted to be fixed in a future release. To receive notifications when more information becomes available, subscribe to this Known Error article by clicking the Subscribe button at the top right of this form.

The indexes listed below are needed for the widget to work. During the upgrade indexes might fail to be applied if your instance reaches the maximum number of indexes on TASK. In that case, open a Case for SN Technical Support, to move from 64 to 128 indexes and create the required indexes:


TABLE INDEX
sc_req_item
  • sys_class_name, cat_item, sys_created_on
  • sys_class_name, cat_item, order_guide
sc_item_produced_record
  • producer, sys_created_on

Related Problem: PRB1386320

Potentially Seen In

There is no data to report.

Fixed In

Xanadu

The world works with ServiceNow.

Sign in for more! There's more content available only to authenticated users Sign in for more!
Did this KB article help you?
Did this KB article help you?

How would you rate your Now Support digital experience?

*

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

What can we improve? Please select all that apply.

What are we doing well? Please select all that apply.

Tell us more

*

Do you expect a response from this feedback?

  • Terms and conditions
  • Privacy statement
  • GDPR
  • Cookie policy
  • © 2025 ServiceNow. All rights reserved.