DEV Community


Discussion on: Build a Raffle with Google Sheet

probszachsean profile image
Zach Sean

Thanks for this! One quick heads up though - as you add additional rows, the script gets incredibly slow. ~400 rows takes a couple minutes to launch, and as I'm currently at ~8300 rows, it's taking 15-20 minutes just to fire up the script.

Any thoughts on how to make this more efficient & faster?

jagedn profile image
Jorge Eψ=Ĥψ Author

Wooaa a raffle with 8300 participants!!! Yes, the problem with my example is that I was thinking in 20-30 participants and I read row by row

The solution comes changing the way we read all rows, so change the for in the getRemains method with:

for(var i=3; i<ss.getLastRow()+1;){
var from = i;
var to = from+100; //google has a max of 100 rows per read
var rows = ss.getRange("A"+from+":D"+to).getValues();
for( r in rows ){

if( !rows[r][0] ){

if( !rows[r][3] ){
// rowIndex, name and surname
ret.push( [i,rows[r][0],rows[r][1]] )



I updated the gist with this change.

Thanks for your comment.

Forem Open with the Forem app