ServiceNow REST API: Fixing Execution Time Errors for Large Table QueriesIssue When querying large tables using the Table API in a ServiceNow instance, REST API requests may fail due to excessive query execution time. For example, customer issued a GET request to collect data from Incident table for one incident with sys_id as following: e644f6b8472bd210bfe841ca116d4320 https://<instance-name>.service-now.com/api/now/v2/table/incident?sys_id=e644f6b8472bd210bfe841ca116d4320 By default, this request first triggers a COUNT(*) query to determine the total number of matching records before retrieving the actual data. It is observed that when the dataset is large, this COUNT query takes longer time to execute and ultimately fails. The failure is caused by a COUNT query exceeding the maximum allowed execution time. Observed Error in Logs: SEVERE *** ERROR *** Exception while executing request: Transaction cancelled: maximum execution time exceededcom.glide.rest.util.RESTRuntimeException: Exception while executing request: Transaction cancelled: maximum execution time exceeded.Caused by: java.sql.SQLException: Query execution was interrupted Query is: SELECT count(*) AS recordcount FROM <Table Name>ReleaseAllCauseRoot Cause: This issue occurs due to the COUNT query executed by default in inbound API requests. By default, the sysparm_no_count parameter is set to false (out-of-the-box behavior).This setting automatically triggers a COUNT(*) query before fetching records.On large tables, executing this query can take too long, ultimately exceeding the maximum allowed execution time and causing the request to fail.ResolutionResolution: To resolve the issue, update the sysparm_no_count parameter in the Table API request to prevent the COUNT query from executing. This adjustment improves performance and prevents the error. Steps to Fix: Modify the API request to include the sysparm_no_count parameter with a value of true: https://<instance_name>.service-now.com/api/now/v2/table/<table_name>?sysparm_no_count=trueTest the updated API request in a non-production environment to confirm that the issue is resolved and functionality is unaffected. This change optimizes query performance, particularly for large tables, by bypassing the COUNT operation that causes excessive execution time.Related LinksFor more details, refer to the ServiceNow Table API Documentation.