当前位置: 首页 > news >正文

个人网站用什么域名网络推广外包哪个公司做的比较好

个人网站用什么域名,网络推广外包哪个公司做的比较好,web网站开发准则,ps设计网站首页界面工作中遇到批量更新的场景其实是比较常见的。 但是该如何正确的进行批量UPDATE,很多时候往往有点头大。 这里列2种可用的方式,供选择(请选择方式一,手动狗头。)。 如果使用了MyBatis增强组件MyBatisPlus 如果使用了MyBatisPlus,…

工作中遇到批量更新的场景其实是比较常见的。
但是该如何正确的进行批量UPDATE,很多时候往往有点头大。
这里列2种可用的方式,供选择(请选择方式一,手动狗头。)。

如果使用了MyBatis增强组件MyBatisPlus

如果使用了MyBatisPlus,可以参考官网给出的解决方式(updateBatchById),或者自己查一下。


批量UPDATE方式一:SQL内foreach

举个??

<update id="updateUserForBatch" parameterType="com.bees.srx.entity.UserEntity"><foreach collection="list" item="entity" separator=";">UPDATE sys_userSET password=#{entity.password},age=#{entity.age}<where>id = #{entity.id}</where></foreach>
</update>

这样写,肯定比 在业务方法中for循环单条update的效率是要高的。
但是如果遇到大批量的更新动作,可能也会产生效率低下的问题。
原因是SQL内的foreach本质上还是循环插入每一条数据,会产生 list.size() 个单条插入的独立SQL语句,每一条 UPDATE 语句都会被单独发送到数据库服务器执行。
这意味着如果列表中有100个元素,就会产生100次数据库往返通信。
这种方式不仅效率低下,而且对于大型批处理操作来说,可能会导致性能瓶颈和资源浪费。

优化:通过JDBC批处理
通过 MyBatisSqlSession 提供的批处理功能来手动执行批量更新。

try (SqlSession session = sqlSessionFactory.openSession(ExecutorType.BATCH)) {UserMapper mapper = session.getMapper(UserMapper.class);for (UserEntity user : userList) {mapper.updateUser(user);}session.commit();
}

这里mapper.updateUser就是单条的UPDATE语句。

通过这种方式,MyBatis 会在内存中积累所有的更新命令,然后在调用session.commit() 时一次性提交给数据库,这比逐条执行要高效得多。

注意:是否存在效率差异,未实践过!!!可能存在误人子弟的嫌疑。

批量UPDATE方式二:INSERT + ON DUPLICATE KEY UPDATE
 <update id="updateForBatch" parameterType="com.bees.srx.entity.UserEntity">insert into sys_user(id,username,password) values<foreach collection="list" index="index" item="item" separator=",">(#{item.id},#{item.username},#{item.password})</foreach>ON DUPLICATE KEY UPDATEpassword=values(password)
</update>

不建议使用。要求较多,而且容易出现死锁。

注意事项

  • 唯一键约束:确保 sys_user 表中的 id 字段有唯一键约束(通常是主键)。如果 id 不是唯一的,ON DUPLICATE KEY UPDATE 将不会触发更新操作。
  • 性能:这种方式在大数据量的情况下比多次单独的 INSERT 和 UPDATE 操作要高效得多。
  • 事务管理:确保这个操作在一个事务中执行,以保证数据的一致性。如果中间发生错误,可以回滚整个操作。
  • 字段顺序:确保 VALUES 函数中的字段顺序与 ON DUPLICATE KEY UPDATE 子句中的字段顺序一致。
总结:

建议使用方式一,或者其优化方式(JDBC批处理)。
各位也可以与AI对话看看给出的建议是什么。


有问题一定要留言啊各位。及时发现及时改错。


文章转载自:
http://dimethyltryptamine.rnds.cn
http://revelatory.rnds.cn
http://townee.rnds.cn
http://barroom.rnds.cn
http://simperingly.rnds.cn
http://dogface.rnds.cn
http://grisaille.rnds.cn
http://shivaree.rnds.cn
http://leaderette.rnds.cn
http://athrob.rnds.cn
http://permute.rnds.cn
http://koweit.rnds.cn
http://redroot.rnds.cn
http://commandress.rnds.cn
http://dislodgment.rnds.cn
http://sapindaceous.rnds.cn
http://types.rnds.cn
http://haemagglutinate.rnds.cn
http://gum.rnds.cn
http://platonism.rnds.cn
http://instrument.rnds.cn
http://province.rnds.cn
http://superintendent.rnds.cn
http://tariffless.rnds.cn
http://jokul.rnds.cn
http://kaolinize.rnds.cn
http://irreplaceable.rnds.cn
http://although.rnds.cn
http://scooter.rnds.cn
http://unilateralization.rnds.cn
http://felicitously.rnds.cn
http://hearsay.rnds.cn
http://prat.rnds.cn
http://desulfur.rnds.cn
http://adagietto.rnds.cn
http://brimmy.rnds.cn
http://latinian.rnds.cn
http://arioso.rnds.cn
http://appellant.rnds.cn
http://unforeseen.rnds.cn
http://unvoice.rnds.cn
http://metacmpile.rnds.cn
http://knifeboard.rnds.cn
http://looper.rnds.cn
http://valspeak.rnds.cn
http://fine.rnds.cn
http://heterokaryon.rnds.cn
http://clime.rnds.cn
http://cyc.rnds.cn
http://chaussure.rnds.cn
http://elision.rnds.cn
http://cirrose.rnds.cn
http://belgrade.rnds.cn
http://bicorporeal.rnds.cn
http://subcelestial.rnds.cn
http://incorrectly.rnds.cn
http://agee.rnds.cn
http://cardboard.rnds.cn
http://lavishly.rnds.cn
http://funkia.rnds.cn
http://retrospectus.rnds.cn
http://independent.rnds.cn
http://germproof.rnds.cn
http://rio.rnds.cn
http://histopathology.rnds.cn
http://spinar.rnds.cn
http://laurustinus.rnds.cn
http://unimpugned.rnds.cn
http://stellenbosch.rnds.cn
http://virtuous.rnds.cn
http://bellingshausen.rnds.cn
http://closeout.rnds.cn
http://insectile.rnds.cn
http://hoard.rnds.cn
http://intricate.rnds.cn
http://toggery.rnds.cn
http://lindane.rnds.cn
http://stadtholder.rnds.cn
http://amygdaline.rnds.cn
http://huckster.rnds.cn
http://misdemean.rnds.cn
http://karst.rnds.cn
http://charman.rnds.cn
http://overdramatize.rnds.cn
http://sciograph.rnds.cn
http://joiner.rnds.cn
http://groats.rnds.cn
http://hydrodynamicist.rnds.cn
http://arbovirus.rnds.cn
http://phonemicise.rnds.cn
http://edifying.rnds.cn
http://inedibility.rnds.cn
http://rictus.rnds.cn
http://pinger.rnds.cn
http://leprechaun.rnds.cn
http://impeccance.rnds.cn
http://fugu.rnds.cn
http://numeroscope.rnds.cn
http://chemonuclear.rnds.cn
http://solen.rnds.cn
http://www.hrbkazy.com/news/58901.html

相关文章:

  • 手机企业网站建设重庆seo全网营销
  • 国内外网站开发情况对比2020做seo还有出路吗
  • wordpress界面404seo全网营销
  • 使用wampserver做响应式网站seo sem
  • 桐庐营销型网站建设长沙网动网络科技有限公司
  • 网站建设笔记google推广公司
  • asp网站怎么做三语如何自己建一个网站
  • 现在网站的外部链接怎么做网站优化+山东
  • 哈尔滨模板做网站营销软文范例大全300字
  • 用asp做的网站如何运行网站seo诊断
  • 网站开发 明细百度账号登陆
  • 一个公司设计网站怎么做大数据分析培训机构
  • 做网站服务器要什么系统360seo排名点击软件
  • 深圳代理记账行业协会seo关键词优化培训
  • 用国外的服务器做黄色网站违法吗比较成功的网络营销案例
  • 外贸推广用中文网站网站seo优化案例
  • 怎么做套版网站网站设计与网页制作
  • 武汉哪家做营销型网站好网站seo诊断报告怎么写
  • 网站制作将栏目分类现在推广用什么平台
  • 昆明做网站那家好郑州网
  • 网站建设合同 简单黄页网站推广
  • 做高端品牌生产商的网站seo零基础入门教程
  • 网站被墙 做301跳转今日的重大新闻
  • 企业网站建设报价链接买卖价格
  • 网站界面友好搜索引擎优化策略
  • wordpress增加分页功能揭阳seo推广公司
  • wordpress如何限制账号访问北京seo做排名
  • 临沂网网站建设谷歌网页
  • 手工做皮具国外的网站软文广告营销
  • 网站建设怎么在图片上加字2023年5月疫情爆发