mysql - 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
我不知道我哪里出错了,我需要帮助来加快这项任务。谢谢
解决方案
推荐阅读
- javascript - 那么MongoDB迁移脚本......?
- css - 如何在一个 css 文件中编写两个媒体查询?
- mysql - SQL 中没有条目时返回 0
- javascript - 是否可以使用排除 / ingore 字符串选项在 mongoose 中进行查询
- javascript - Javascript - 在 for 循环中的条件检查中附加一次
- java - ScheduledExecutorService 没有创建并发线程
- environment-variables - Julia:未能将 PyCall 配置为使用不同的版本
- graphdb - GraphDB 自定义规则集,用于通过 RDF* 语句进行推理
- javascript - 在 reactJs 中创建带有标题的动态表的问题
- python - 元素单击 Selenium 未找到要单击的按钮