在rethinkDB中,我要求使用一些唯一的数据引用逐个执行10000更新查询。它运行但需要25到30 所有10000条记录执行的分钟数。我不知道是什么问题?为什么查询运行速度很慢?
let mergeDuplicateContactsInDB = (data) => {
try {
return new Promise((resolve, reject) => {
let arrPromise = [];
let primaryRecordIden;
if (data.arrMergeIdens.length > 0) {
forEach(data.arrMergeIdens, (arrContactIdens, index) => {
if (arrContactIdens.length > 0) {
arrPromise.push(
new Promise((resolve, reject) => {
primaryRecordIden = arrContactIdens[0];
arrContactIdens.splice(0, 1);
delete data.finalMergedData[index]['id'];
arrDeletedIden = arrDeletedIden.concat(arrContactIdens);
rdbdash.table("person")
.filter({
"id": primaryRecordIden
})
.update(data.finalMergedData[index])
//.run(DBConfig.rConnection(), function (err, cursor) {
.run()
.then((result) => {
if (!!result) {
return resolve(true);
}
});
})
);
}
});
Promise.all(arrPromise).then((data) => {
resolve({
"processed_data_length": data.length
});
});
} else {
resolve({
"processed_data_length": 0
});
}
});
} catch (e) {
throw new Error(e);
}
};