SNOW-CAD Working with Data Practice Question
During a data migration, a developer runs a GlideRecord query to load 100,000 records from an external source into the 'incident' table. The script times out after 60 seconds. Which optimization technique would be most effective to avoid the timeout?
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Use GlideRecordBatch or a scheduled job to process records in smaller batches.
Using GlideRecordBatch or a scheduled job with incremental processing breaks the workload into manageable chunks, preventing the script from timing out. Option A is incorrect because setLimit(1000) only limits the number of records returned per query, but the migration requires all 100,000 records to be processed; it does not solve the timeout issue when processing large batches. Option B is incorrect because GlideAggregate is used for aggregation queries (e.g., counting records) and does not assist in batch insertion of records. Option C is incorrect because increasing the transaction timeout is a temporary workaround; it does not address the underlying efficiency problem and may lead to other performance issues.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Use setLimit(1000) to reduce the number of records per execution.
Why it's wrong here
Setting a limit reduces the number of records returned per query, but the migration still needs to process all 100,000 records. It does not prevent timeout because the script still attempts to process all records in one go, just with fewer returned each time; actually, setLimit would only return up to 1000 records, losing the rest. This option is incorrect.
- ✗
Use GlideAggregate to count records before insertion.
Why it's wrong here
GlideAggregate is designed for aggregate functions like SUM, COUNT, AVG, etc. It does not help with inserting records in batches. Using it to count records before insertion does not address the timeout caused by large batch insertions. This option is incorrect.
- ✗
Increase the transaction timeout setting in the system properties.
Why it's wrong here
Raising the transaction timeout merely extends the window before termination, but does not address the root cause: the GlideRecord query loads all 100,000 records into memory at once, exhausting script execution time regardless of the timeout value. This setting is tempting because it can resolve timeouts caused by legitimate long-running operations, such as a scheduled job processing a large batch over a network with high latency, where the operation itself is efficient but needs more clock time to complete.
- ✓
Use GlideRecordBatch or a scheduled job to process records in smaller batches.
Why this is correct
Using GlideRecordBatch or a scheduled job allows the developer to process records in smaller, manageable batches. This prevents the script from running for too long in a single transaction, thereby avoiding the timeout while still processing all records. This is the most effective optimization technique.
Go deeper
Related to this question
About these practice questions
One of 481 original SNOW-CAD practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This SNOW-CAD practice question is part of Courseiva's free ServiceNow certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the SNOW-CAD exam.