0
我有多個customerKey值分配給一個數值的表;我寫了一個腳本,其中每行數據掃描整個表以查找分配給當前customerKey的所有值並返回最高值;性能服務器腳本
我有一個性能問題 - 腳本進程每秒大約10條記錄 - 任何想法如何改進或者可能提出一個替代解決方案plesae?
function getLastest() {
var date = app.models.magicMain.newQuery();
var date_all = date.run();
date_all.forEach(function(e) { // for every row of date_all
var temp = date_all.filter(function(x) {
return x.SubscriberKey === e.SubscriberKey; // find matching records for the current x.SubscriberKey
});
var dates = [];
temp.forEach(function(z) { // get all matching "dates"
dates.push(z.Date);
});
var finalValue = dates.reduce(function(a, b) { // get highest dates value (integer)
return Math.max(a, b);
});
var record = app.models.TempOperatoins.newRecord(); // save results to DB
record.email = e.SubscriberKey.toString() + " " + finalValue.toString();
app.saveRecords([record]);
});
}