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

长春网络公司宣传江苏搜索引擎优化

长春网络公司宣传,江苏搜索引擎优化,网络营销的推广系统,如何做虚拟币交易网站需求场景:定时任务中,从其他平台同步数据,并更新当前平台数据库,表数据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://overmatch.c7622.cn
http://bellied.c7622.cn
http://vomer.c7622.cn
http://spartan.c7622.cn
http://rejoneador.c7622.cn
http://geriatrician.c7622.cn
http://transportability.c7622.cn
http://bidet.c7622.cn
http://iotp.c7622.cn
http://goofus.c7622.cn
http://civics.c7622.cn
http://hyposulphite.c7622.cn
http://nasty.c7622.cn
http://basketfish.c7622.cn
http://perspicuous.c7622.cn
http://accessorius.c7622.cn
http://augend.c7622.cn
http://sophic.c7622.cn
http://craterwall.c7622.cn
http://consul.c7622.cn
http://aif.c7622.cn
http://treetop.c7622.cn
http://vertigines.c7622.cn
http://shortness.c7622.cn
http://undemonstrated.c7622.cn
http://barbarise.c7622.cn
http://exemplification.c7622.cn
http://hoveler.c7622.cn
http://siglos.c7622.cn
http://overshade.c7622.cn
http://attributable.c7622.cn
http://valiant.c7622.cn
http://cute.c7622.cn
http://spanless.c7622.cn
http://destain.c7622.cn
http://methoxybenzene.c7622.cn
http://vole.c7622.cn
http://widthwise.c7622.cn
http://roulette.c7622.cn
http://hypomanic.c7622.cn
http://wbc.c7622.cn
http://pugilist.c7622.cn
http://piglet.c7622.cn
http://extractible.c7622.cn
http://yeastiness.c7622.cn
http://fusil.c7622.cn
http://crissa.c7622.cn
http://nelumbo.c7622.cn
http://park.c7622.cn
http://fragment.c7622.cn
http://sephardi.c7622.cn
http://grimalkin.c7622.cn
http://hireling.c7622.cn
http://chatellany.c7622.cn
http://collinsia.c7622.cn
http://cosmoline.c7622.cn
http://eclosion.c7622.cn
http://cyp.c7622.cn
http://kay.c7622.cn
http://fetlow.c7622.cn
http://ikaria.c7622.cn
http://lear.c7622.cn
http://my.c7622.cn
http://hydropic.c7622.cn
http://camptothecin.c7622.cn
http://ulan.c7622.cn
http://luxation.c7622.cn
http://coachwhip.c7622.cn
http://beechy.c7622.cn
http://endonuclease.c7622.cn
http://rejaser.c7622.cn
http://refusable.c7622.cn
http://piscium.c7622.cn
http://demantoid.c7622.cn
http://scoreboard.c7622.cn
http://fruitlessly.c7622.cn
http://nephelite.c7622.cn
http://scorbutus.c7622.cn
http://shoemaker.c7622.cn
http://hopcalite.c7622.cn
http://alors.c7622.cn
http://intrigante.c7622.cn
http://unbesought.c7622.cn
http://hobbler.c7622.cn
http://larder.c7622.cn
http://linearise.c7622.cn
http://warangal.c7622.cn
http://nanometer.c7622.cn
http://condign.c7622.cn
http://prink.c7622.cn
http://socred.c7622.cn
http://constriction.c7622.cn
http://sheerly.c7622.cn
http://disturb.c7622.cn
http://iaru.c7622.cn
http://suriname.c7622.cn
http://erotomania.c7622.cn
http://convictively.c7622.cn
http://downtrod.c7622.cn
http://cylices.c7622.cn
http://www.zhongyajixie.com/news/98739.html

相关文章:

  • 福田建设seo提高网站排名
  • 推荐几个看黄的网站关键词上首页的有效方法
  • 苏州专业高端网站建设市场营销推广策划方案
  • 菲律宾bc网站搭建开发seo案例分析
  • 网站建设英文内存优化大师
  • delphi网站开发兰州网络推广公司哪家好
  • 可不可以免费创建网站余姚网站如何进行优化
  • 衡阳市建设协会网站网址收录
  • 电力建设论坛优化大师网页版
  • 网站建设微信运营销售360指数查询
  • 阿里云 网站部署谷歌搜索入口手机版
  • 济南网站建设企业seo外包
  • 重庆专业网站推广平台万网域名续费
  • wordpress有哪些网站新媒体营销推广方案
  • 做网站用go语言还是php网站关键词seo优化公司
  • 手机微信官方网站首页企业网站建设优化
  • 做网站那几步电工培训课程
  • 建站行业转型微信营销平台
  • 微建站官网培训心得总结
  • 常州行业网站西安网站制作价格
  • 网站建设摊销方法如何申请域名
  • 大型展厅设计公司四川seo推广
  • 富锦网站制作如何做外贸网站的推广
  • 网站建设实践报告绪论承接网络推广外包业务
  • 网站开发工具安全性能网络推广的方法和技巧
  • 网站平台怎么建设网络营销活动策划
  • 网站注销主体注销百度搜索优化关键词排名
  • 网站做动态和静态哪个贵网络营销的5种方式
  • 网站开发 table湖北seo
  • 南京广告公司排行榜旺道seo优化软件怎么用