首页 > 解决方案 > MYSQL删除重复数据需要10多个小时

问题描述

我是 MYSQL 的新手。我想删除我表上的重复数据,但它仍然需要一整天的时间才能运行,就像它处于无限循环中一样。这是我运行的一个脚本,用于清除包含 5000 个数据组合的表上的所有重复数据。

DELETE en1
     , cm1
     , reg1
     , yr1
     , cmod1
     , mocat1
     , sem1
     , ex1
     , pen1
     , exdet1
     , excat1
     , exres1 
  FROM student_class_enrollment en1
     , acad_class_course_module cm1
     , student_registration_id reg1
     , college_academic_years yr1
     , acad_course_module cmod1
     , acad_class_course_module_category mocat1
     , semester sem1
     , acad_class_course_module_exam ex1
     , acad_course_module_penalty pen1
     , acad_class_course_module_exam_detail exdet1
     , acad_class_exam_category excat1
     , acad_class_course_module_exam_result exres1
  JOIN student_class_enrollment en2
     , acad_class_course_module cm2
     , student_registration_id reg2
     , college_academic_years yr2
     , acad_course_module cmod2
     , acad_class_course_module_category mocat2
     , semester sem2
     , acad_class_course_module_exam ex2
     , acad_course_module_penalty pen2
     , acad_class_course_module_exam_detail exdet2
     , acad_class_exam_category excat2
     , acad_class_course_module_exam_result exres2
 WHERE en1.id < en2.id 
   and cm1.id < cm2.id 
   and reg1.id < reg2.id 
   and yr1.id < yr2.id 
   and cmod1.id < cmod2.id 
   and mocat1.id < mocat2.id 
   and sem1.id < sem2.id  
   and ex1.id < ex2.id 
   and pen1.id < pen2.id 
   and exdet1.id < exdet2.id 
   and excat1.id < excat2.id 
   and exres1.id < exres2.id
   and en1.id = en2.id 
   and en1.student_id = en2.student_id 
   and cmod1.code = cmod2.code 
   and exres1.raw_mark = exres2.raw_mark 
   and excat1.cat_code = excat2.cat_code 
   and exdet1.ex_weight = exdet2.ex_weight

我不知道我哪里出错了,我需要帮助来加快这项任务。谢谢

标签: mysql

解决方案


推荐阅读