Error Reference

Large record count warning: query returned excessive rows

Large record count warning: query returned excessive rows

Where this appears

This warning appears in the ServiceNow application log and system diagnostics when a GlideRecord query executes without proper row limits. The error typically occurs during script execution in business rules, scheduled jobs, or background scripts when queries return more records than the system's configured warning threshold.

Sourdough
Chrome Extension

Debugging this in a real instance?

Sourdough lets you trace "Large record count warning: query returned excessive rows" through system logs, script errors, and API health in the ServiceNow tab you are already using.

Add to Chrome

Free to install. Pro $5/month after a 14-day no-card trial.
Pro requires the ServiceNow admin role. Upgrade inside the extension.

Overview
Tasks
CMDB
API
Metrics
Monitor
Internals
Instance:sourdoughdev·Version:Yokohama
Instance StateONLINE
System StatusFully Operational
Session Timeout90 minutes
Logged-In Sessions2 (20 active)
Build Nameyokohama-12-18-2024_p1
IP Address10.159.128.43
Instance HealthHealth Score: 90%
🔥 5dSourdough (Chrome Plugin)Dark Mode

Cause

GlideRecord query executed without setLimit() method on tables with large datasets, causing memory consumption warnings when row count exceeds the glide.db.max_view_records system property threshold. (high likelihood)

Broad query conditions using addQuery() with wildcards or generic filters that match significantly more records than expected, particularly on high-volume tables like sys_audit or sys_journal_field. (high likelihood)

Missing or ineffective query conditions in GlideRecord scripts, resulting in table scans that return entire table contents rather than filtered result sets. (medium likelihood)

Scheduled jobs or background scripts processing large data sets without implementing proper pagination logic, causing single queries to load excessive records into server memory. (medium likelihood)

Integration scripts or data import processes attempting to query large reference tables without appropriate filtering or chunking mechanisms in place. (low likelihood)

Fix

Step 1: Check System Diagnostics > Log > Application Log to identify the specific script and line number generating the large record count warning.

Step 2: Examine the problematic GlideRecord query in the identified script and verify current query conditions using addQuery() methods to ensure they are sufficiently restrictive.

Step 3: Add setLimit() method to the GlideRecord query with an appropriate maximum row count, typically setLimit(1000) or less depending on processing requirements.

Step 4: Implement pagination logic using setLimit() combined with query offset techniques or iterative processing to handle large datasets in manageable chunks.

Step 5: Review and optimize query conditions by adding more specific filters, date ranges, or status conditions to reduce the total number of matching records.

Step 6: Test the modified query in a background script or fix script environment to verify it returns an acceptable number of records without triggering warnings.

Step 7: Monitor the System Log after deployment to confirm the large record count warnings no longer appear for the modified queries.

Step 8: Document the pagination approach and query limits for future maintenance and similar implementations across the instance.

Test Your Knowledge

Quick 3-question quiz. See how your ServiceNow skills stack up.

Question 1 of 3Performance

A list view on a table with millions of records is slow. Best fix?

Select an answer to continue