使用唯一索引+insert_many+ordered=false

insert_many方法本质上也是bulk操作,但它较update少了搜索的部分,因此理论上更快。
同时也是因为没有进行搜索就插入,它没有办法判断插入的数据是否存在,这点就需要通过item_id上的唯一索引来确保。
同时默认情况下insert_many使用ordered=true,遇到一个插入错误(item_id重复)就停止了,所以需要ordered=false

相关文章:

  • 2022-01-13
  • 2021-06-24
  • 2021-12-01
  • 2022-12-23
  • 2021-11-13
  • 2021-11-02
猜你喜欢
  • 2021-11-07
  • 2021-11-20
  • 2022-12-23
  • 2021-08-15
  • 2022-12-23
  • 2021-12-12
相关资源
相似解决方案