Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Case Analysis of Multi-parameter efficiency of batch deletion of mybatis

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

Batch deletion of mybatis multi-parameter efficiency example analysis, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

Recently, I have encountered the problem of deleting table data in batches and based on multiple parameters. In my case, I have a special parameter that is the same value, but I still use it as a general case. An experimental test has been done.

The code test is as follows:

Map param = new HashMap (); param.put ("userId", userId); List listJobIds = sysUserJobdel.stream (). Map (SysUserJob::getJobId). Distinct (). Collect (Collectors.toList ()); param.put ("jobIds", listJobIds); for (int I = 0; I < 10000; iTunes +) {SysUserJob userJob = new SysUserJob (); userJob.setJobId (String.valueOf (SystemUtils.nextId (); userJob.setUserId (userId); sysUserJobdel.add (userJob) ListJobIds.add (String.valueOf (SystemUtils.nextId ();} param.put ("jobIds", listJobIds); long begintime1 = System.currentTimeMillis (); sysUserMapper.deleteUserJobs (param); long endtime1 = System.currentTimeMillis (); long costTime1= (endtime1-begintime1); System.err.println ("costTime1====" + costTime1); long begintime2 = System.currentTimeMillis (); sysUserMapper.deleteUserJob (sysUserJobdel); long endtime2 = System.currentTimeMillis (); long costTime2= (endtime2-begintime2); System.err.println ("costTime2====" + costTime2) Long begintime3 = System.currentTimeMillis (); sysUserMapper.deletesUsersJobs (sysUserJobdel); long endtime3 = System.currentTimeMillis (); long costTime3= (endtime3-begintime3); System.err.println ("costTime3====" + costTime3) Delete from sys_user_job where user_id = # {userId} and job_id in# {item} delete from sys_user_job where (user_id = # {item.userId} and job_id= # {item.jobId}) delete from sys_user_job where (user_id,job_id) in (# {item.userId}, # {item.jobId})

Three result outputs:

CostTime1====173

CostTime2====1673

CostTime3====414

CostTime1====115

CostTime2====1523

CostTime3====391

CostTime1====105

CostTime2====1501

CostTime3====417

After reading the above, have you mastered the method of batch deletion of mybatis multi-parameter efficiency case analysis? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report