I’m working on an Apps Script that reads data from multiple Google Sheets, processes it in memory, and then writes the final result back to a destination sheet.
For smaller datasets everything works fine, but as the number of rows and columns increases, I’m wondering about the best approach for writing the data efficiently.
Would you recommend using one large setValues() call, or splitting the data into smaller batches?
For example, if I have around 500–1,000 rows and 100+ columns, is there any significant advantage to batching the writes, or is a single setValues() generally preferable?
Also, are there any other Apps Script/Sheets practices you use to avoid timeout, quota, or intermittent service errors when working with larger datasets?
Interested to hear how others are handling this in production.
We ran into this quite a bit while building AdminSheet Pro, which is an Apps Script-based Google Workspace add-on for Google Workspace admins.
For your 500–1,000 rows × 100+ columns case, if the data is already in memory, I’d normally start with a single setValues() call rather than splitting it into lots of smaller writes. Reducing calls between Apps Script and Sheets generally matters more than the size of each individual write at that scale.
One option worth testing as the dataset grows is the Advanced Sheets Service (Sheets API). We’ve found it useful when we need more direct control over larger operations, particularly through methods such as Sheets.Spreadsheets.Values.update() or batchUpdate(). I wouldn’t automatically switch to it for every write, but it’s definitely worth comparing once SpreadsheetApp becomes a bottleneck.
Where batching became really important for us was when the operation involved more than just writing to Sheets, especially Admin SDK/API calls and bulk Workspace operations. At that point, the bigger problem becomes Apps Script’s 6-minute execution limit. We ended up using a state-aware approach: process a batch, save the current position, exit before the execution limit, then resume from where we stopped in the next execution. I wrote about the approach in more detail in another post in this forum.
A few other things that have helped us: keep the processing in arrays in memory, minimise calls to getValues()/setValues(), avoid SpreadsheetApp.flush() inside loops, and retry transient API errors rather than restarting the whole job.
So for your specific example, I’d start with onesetValues(), test the Advanced Sheets Service if performance becomes an issue, and only introduce batching when execution time, external APIs or recoverability make it necessary.
Use a single setValues() call whenever the full array fits comfortably in memory and matches the target range dimensions. For 500–1,000 rows × 100+ columns, one write is normally faster and more reliable than batching because it minimizes calls to the Sheets service.
Batch only when the output is very large, memory is tight, or you see execution/service errors. If needed, use chunks such as 2,000–10,000 rows per write—not tiny batches.
The main production rule is to read once, process arrays in memory, and write once. Avoid getValue()/setValue() inside loops, avoid repeated formatting operations, and clear only the exact range you need. If the job may exceed Apps Script’s execution limit, split work across runs and store progress with PropertiesService or a time-based trigger.
Albert’s guidance is sound, and a single setValues call will beat chunked writes for 500 to 1,000 rows by a wide margin. The Advanced Sheets Service becomes worthwhile when you are pushing much larger volumes or need batchUpdate for formatting and other operations. The state-aware batching for the six-minute limit is the piece worth noting. Read once, process in memory, write once. That pattern survives most scaling problems.
For 500–1,000 rows and 100+ columns, if the data is already in memory I’d just do one setValues() call. At that size the number of calls matters more than batch size, so one write is usually faster and more reliable than splitting it up.
Things that have helped me in production:
Read everything once with getValues(), process it in a plain JS array, then write it back once with setValues(). Avoid getValue() and setValue() inside loops.
Skip flush() inside loops and only clear the exact range you need.
If you’re getting close to the 6 minute limit, save your progress with PropertiesService, stop before the timeout, and pick up where you left off on the next trigger.
Retry transient API errors instead of restarting the whole job.
If SpreadsheetApp starts slowing down as the data grows, the Advanced Sheets Service is worth testing, but I wouldn’t switch to it for every write.
So for your case I’d start with a single setValues() and only batch when execution time or recoverability actually makes it necessary.