SNOW-CAD Working with Data Practice Question
A developer writes a script include that uses GlideRecord to query a large table. The script is called multiple times in a single transaction. What is the best practice to optimize performance?
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 a single GlideRecord query with multiple conditions and call .getRowCount() at the end.
When a script include queries a large table multiple times in a single transaction, the best practice is to minimize database round-trips. Using a single GlideRecord query with multiple conditions (combined via OR/AND) reduces the number of queries executed. Calling .getRowCount() at the end forces the query to execute once and caches the result, avoiding redundant queries for counts. This is more efficient than separate queries (A), which each require a round-trip. createOrGetRecord (B) is designed for single-record operations and doesn't optimize multiple queries. setEncodeQuery(false) (D) disables encoding but does not improve performance for repeated calls.
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 separate GlideRecord queries for each call.
Why it's wrong here
Wrong: Multiple queries increase overhead.
- ✗
Use createOrGetRecord for each call to cache the result.
Why it's wrong here
Wrong: createOrGetRecord is for single record caching, not queries.
- ✓
Use a single GlideRecord query with multiple conditions and call .getRowCount() at the end.
Why this is correct
Correct: This minimizes database round trips.
- ✗
Use setEncodeQuery(false) to speed up the query.
Why it's wrong here
Wrong: Encoding does not significantly affect performance.
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.