【发布时间】:2016-04-15 15:38:31
【问题描述】:
我有一个场景,其中列出了 1000 名员工(示例如下),他们的余额在每个月末更新,其中每个员工的余额可能不同。
{
_id:1
name:"John"
balance:40
},
现在执行相同操作的最佳做法是什么。一个一个地执行
for (Employee employee : employeeList) {
employee.update();
}
或
dropAll employees where id in (All employees ids)
mongoOperations.insert(employeeList, Employee.class);
或者第三种方法可以是
Load all employee records.
Insert employee records to a new collection say employee_temp.
Drop old collection (employee).
Rename newly inserted collection as old one (employee).
或者是他们的任何其他方式可以保证数据库数据完整性的最大成功机会以及从性能角度来看良好。
【问题讨论】:
标签: mongodb spring-data spring-data-mongodb