Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

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

Shulou Source: shulou.com Published: 2022-06-02 01:56:39 09月28日 Update

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!

Tags: Parameters problems examples case analysis efficiency analysis content situation methods more testing special helpless for this code reasons parameter comparison multiple for this skills Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia MySQL Xiaomi Microsoft Docker