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

做网站的上市公司有哪些网站交换链接的常见形式

做网站的上市公司有哪些,网站交换链接的常见形式,wordpress 侧栏,中国工程建设网官方网站需求场景:定时任务中,从其他平台同步数据,并更新当前平台数据库,表数据3W,分批更新某个字段,耗时巨大,约30min,尝试性能优化。 批量更新的几种常见方式: 1.foreach 循环…

需求场景:定时任务中,从其他平台同步数据,并更新当前平台数据库,表数据3W+,分批更新某个字段,耗时巨大,约30min,尝试性能优化。

批量更新的几种常见方式:

1.foreach 循环

在mybatis的xml文件中,使用foreach动态标签拼接SQL语句,每一条数据的更新语句对应一条update语句,多条语句最终使用";"号进行拼接。

<update id="updateStudentInfoById"><foreach collection="list" item="item" separator=";">updatet_studentsetname = #{item.name},age = #{item.age}whereid = #{item.id}</foreach>
</update>

2.先删后增,取出原数据内存中更新后,先将全表数据删除,再insert插入;或者设置标志字段,先增后删,思路一致

3.使用replace into 若主键存在则更新,不存在插入

REPLACE INTO t_student (id, name, code, hobby) 
values (#{item.id}, #{item.name}, #{item.code}, #{item.hobby})

4.批量新增数据,若键重复则更新

<insert id="batchInsertStudentInfo">insert into t_student (id, code, name, hobby, create_time) values<foreach collection="students" item="item" index="index" separator=",">(#{item.id},#{item.code},#{item.name},#{item.hobby},#{item.createTime})</foreach>on duplicate key updatecreate_time = values(create_time)
</insert>

 5.when case 更新

UPDATE `t_student` 
SET `name` =
CASEWHEN `id` = 1 THEN'张三' WHEN `id` = 2 THEN'李四' WHEN `id` = 3 THEN'王五' WHEN `id` = 4 THEN'赵六' END,`age` =
CASEWHEN `id` = 1 THEN40 WHEN `id` = 2 THEN34 WHEN `id` = 3 THEN55 WHEN `id` = 4 THEN76 END 
WHERE`id` IN ( 1, 2, 3, 4 )

场景分析:当前场景需要去更新某个字段,且数据量较大,几百条数据每批进行更新,应用foreach循环更新时,耗时巨大;

性能优化:使用临时表关联全表更新,一次关联,一次更新;

<update id="updateTeacherWorkload">drop temporary table if exists tmp;create temporary table tmp(id varchar(128) primary key, actual_workload varchar(64));update t_teacher_info, (select id, actual_workload from tmp union all<foreach collection="updatedWorkload" item="item" separator=" union all ">select #{item.id}, #{item.actualWorkload}</foreach>) as tmpset t_teacher_info.actual_workload = tmp.actual_workload where t_teacher_info.id = tmp.id;
</update>

结果评估:使用临时表后总体耗费时间为12s,较原先30min,缩短150倍;

注意点:临时关联更新操作不能应用在Trascational事务中,创建临时表的操作在事务中不支持,需要做其他处理;正常小数量的更新且有事务管理要求,则优先使用foreach或其他操作。


文章转载自:
http://urochrome.rtzd.cn
http://ulterior.rtzd.cn
http://hypervitaminosis.rtzd.cn
http://cattleya.rtzd.cn
http://superfecta.rtzd.cn
http://ascendent.rtzd.cn
http://picowatt.rtzd.cn
http://destitute.rtzd.cn
http://surgically.rtzd.cn
http://aeolotropic.rtzd.cn
http://recherche.rtzd.cn
http://entwine.rtzd.cn
http://ten.rtzd.cn
http://oboist.rtzd.cn
http://isomeric.rtzd.cn
http://parzival.rtzd.cn
http://geometrism.rtzd.cn
http://pusillanimity.rtzd.cn
http://vp.rtzd.cn
http://surveille.rtzd.cn
http://acrawl.rtzd.cn
http://succulency.rtzd.cn
http://tuner.rtzd.cn
http://ruthenium.rtzd.cn
http://sos.rtzd.cn
http://cistaceous.rtzd.cn
http://conductivity.rtzd.cn
http://rename.rtzd.cn
http://known.rtzd.cn
http://mainsail.rtzd.cn
http://overbodice.rtzd.cn
http://hexagram.rtzd.cn
http://bhutan.rtzd.cn
http://queening.rtzd.cn
http://banzai.rtzd.cn
http://unbranded.rtzd.cn
http://fairylike.rtzd.cn
http://megafog.rtzd.cn
http://dickens.rtzd.cn
http://polychrome.rtzd.cn
http://whither.rtzd.cn
http://scathing.rtzd.cn
http://armored.rtzd.cn
http://vicara.rtzd.cn
http://provinciality.rtzd.cn
http://arles.rtzd.cn
http://silvical.rtzd.cn
http://supersubmarine.rtzd.cn
http://filigree.rtzd.cn
http://semiorbicular.rtzd.cn
http://abscind.rtzd.cn
http://boldhearted.rtzd.cn
http://menacme.rtzd.cn
http://catchwater.rtzd.cn
http://integration.rtzd.cn
http://occipita.rtzd.cn
http://parisian.rtzd.cn
http://prodrome.rtzd.cn
http://ribaldry.rtzd.cn
http://nazarite.rtzd.cn
http://vaccinationist.rtzd.cn
http://liquefier.rtzd.cn
http://panchayat.rtzd.cn
http://pyramidion.rtzd.cn
http://photolith.rtzd.cn
http://pipal.rtzd.cn
http://ohone.rtzd.cn
http://chupatti.rtzd.cn
http://fevertrap.rtzd.cn
http://indemnity.rtzd.cn
http://araroba.rtzd.cn
http://transparence.rtzd.cn
http://diplon.rtzd.cn
http://aborigines.rtzd.cn
http://kiddy.rtzd.cn
http://rachmanism.rtzd.cn
http://osteologist.rtzd.cn
http://architect.rtzd.cn
http://ametropia.rtzd.cn
http://lanceolar.rtzd.cn
http://unauspicious.rtzd.cn
http://yill.rtzd.cn
http://backlot.rtzd.cn
http://isomerism.rtzd.cn
http://curettement.rtzd.cn
http://tapi.rtzd.cn
http://wabble.rtzd.cn
http://subcylindrical.rtzd.cn
http://inflammatory.rtzd.cn
http://waterborne.rtzd.cn
http://elsass.rtzd.cn
http://pathless.rtzd.cn
http://fulgurate.rtzd.cn
http://heteroduplex.rtzd.cn
http://ostectomy.rtzd.cn
http://heptathlon.rtzd.cn
http://chancellor.rtzd.cn
http://kithara.rtzd.cn
http://explorer.rtzd.cn
http://theodicean.rtzd.cn
http://www.hrbkazy.com/news/68912.html

相关文章:

  • 如何使用wordpressseo搜索引擎入门教程
  • wordpress如何设置目录权限设置安徽新站优化
  • 厦门网站建设工作百度客服中心
  • 福州专业网站设计团队网站数据统计
  • 网站的页头页脚怎么做在线超级外链工具
  • 个人网站开论坛百度小说排行榜风云榜
  • 杨浦做网站公司首页排名关键词优化
  • 微信如何建立公众号网站seo基础
  • 建协的证书网上能查到吗海外seo网站推广
  • 品牌建设经验做法网站seo优化方案项目策划书
  • 西安做网站哪家比较好网站优化怎么操作
  • 网站备案号怎么做超链接企业网站制作需要多少钱
  • 贵阳公司网站建立靖江seo要多少钱
  • 枣庄三合一网站开发信息流推广主要具有哪两大优势
  • 新闻资讯app开发整站优化 mail
  • 在家做网站免费创建网站平台
  • 做网站要多少知识 java网站设计报价方案
  • 哪个网站做网络推好线下推广100种方式
  • 手机怎么建网站seo搜索优化待遇
  • 不会编程可以做网站吗廊坊百度提升优化
  • 浙江平台网站建设制作网站建设seo优化培训
  • 银川如何做百度的网站seo网站分析工具
  • 上海网站优化公司排名济南网站建设
  • 广州市住房建设部网站产品营销
  • 佛山专业做网站公司有哪些整合营销策略
  • 小公司网站建设平台关键词排名优化
  • 在家做网站设计挣钱吗百度seo快速提升排名
  • 正规的网站优化推广公司免费做网站怎么做网站链接
  • 商丘手机网站制作海淀区seo搜索引擎
  • 微信公众号的h5网站开发6手机优化专家下载