I have more than 1000000 record how to speed up search in sheet. I normally search for 20s how to improve ? (sheet include 20 column and 10000 record)
var ss = SpreadsheetApp.openByUrl(urldb);
var ws = ss.getSheetByName("Account");
var data = ws.getDataRange().getValues();
for(var i = 0; i < data .length; i++){
if(data [i][1] == "ID998724"){
Logger.log("found you" + data [i][1]);
}
};
return data[i][1];
ID998724
form the column "B" on the sheet of "Account" in Spreadsheet using Google Apps Script.If my understanding is correct, how about these 3 sample scripts? Please think of this as just one of several answers.
Sample script 1:
In this script, I used Class TextFinder for this situation. This was added in a recent update of Google.
Sample script 2:
In this script, the values are retrieved from the column "B". This is also mentioned at ross's comment. And also from the result of benchmark, I used
filter()
for this situation.Sample script 3:
In this script, I used Query Language for this situation.
Note:
return data[i][1]
. Becausei
is the same withdata.length
. If you want to retrieve the value byreturn data[i][1]
, for example, please putbreak
afterLogger.log("found you" + data [i][1])
.References:
If I misunderstood your question and these sample scripts were not the results you want, I apologize.