标签:
有个同学,说是系统中出现性能问题了,说是让我帮助诊断一下。本来是不想花这时间的,结果耐不住对方的死缠乱打,只要答应帮看看。 故事发生的背景是,在文件上传的时候,有时间会有人上传了文件,但是最后没有使用上传的文件,这样就会产生一些垃圾文件。1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
void deleteMissLinkFile{ List fileList=getFileList(); List deleteFileList=new ArrayList(); for(file:fileList){ int count1=execute(select count(*) from ...); int count2=execute(select count(*) from ...); int count3=execute(select count(*) from ...); int count4=execute(select count(*) from ...); int count5=execute(select count(*) from ...); if(count1==0&&count2==0&&count3==0&&count4==0&&count5==0){ deleteFileList.add(file); } } delete(deleteFileList); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
void deleteMissLinkFile{ List fileList=getFileList(); List deleteFileList=new ArrayList(); for(file:fileList){ int count1=execute(select count(*) from ...); if(count1>0)continue; int count2=execute(select count(*) from ...); if(count2>0)continue; int count3=execute(select count(*) from ...); if(count3>0)continue; int count4=execute(select count(*) from ...); if(count4>0)continue; int count5=execute(select count(*) from ...); if(count1>0)continue; deleteFileList.add(file); } delete(deleteFileList); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
void deleteMissLinkFile{ List fileList=getFileList(); List refList1=execute(select file from tb1…) for(ref:refList1){ fileList.remove(ref) } List refList2=execute(select file from tb2…) for(ref:refList2){ fileList.remove(ref) } …… delete(deleteFileList); } |
版权声明:本文为博主原创文章,未经博主允许不得转载。
《开源框架那些事儿27》悠然乱弹:一段SQL引发的性能危机及其背后隐藏的设计缺陷
标签:
原文地址:http://blog.csdn.net/j2eetop/article/details/47613191