Oracle Deduping花了太长时间

时间:2016-07-11 12:32:43

标签: sql oracle

所以我在桌子上有一些完美的欺骗,我上周从生产中拉下来(在一天结束时) 我很确定我没有勾选TOAD中的截断第一个框并且在我的桌子中有一堆很好的欺骗。 我正在运行以下查询:

DELETE
from MMI_OWNER.IMART_TTI_RET_MY_CUSTOMERS A1
where exists (Select 'x' from MMI_OWNER.IMART_TTI_RET_MY_CUSTOMERS A2
              where A1.ROWID <> A2.ROWID
              and   ((A1.MEASURE_ID = A2.MEASURE_ID) or ((A1.MEASURE_ID is null) and (A2.MEASURE_ID is null)))
              and   ((A1.MEASURE_NAME = A2.MEASURE_NAME) or ((A1.MEASURE_NAME is null) and (A2.MEASURE_NAME is null)))
              and   ((A1.MEASURE_DESCRIPTION = A2.MEASURE_DESCRIPTION) or ((A1.MEASURE_DESCRIPTION is null) and (A2.MEASURE_DESCRIPTION is null)))
              and   ((A1.MEASURE_FORMAT = A2.MEASURE_FORMAT) or ((A1.MEASURE_FORMAT is null) and (A2.MEASURE_FORMAT is null)))
              and   ((A1.ENTITY_ID = A2.ENTITY_ID) or ((A1.ENTITY_ID is null) and (A2.ENTITY_ID is null)))
              and   ((A1.ENTITY_DESCRIPTION = A2.ENTITY_DESCRIPTION) or ((A1.ENTITY_DESCRIPTION is null) and (A2.ENTITY_DESCRIPTION is null)))
              and   ((A1.PARENT_ENTITY_ID = A2.PARENT_ENTITY_ID) or ((A1.PARENT_ENTITY_ID is null) and (A2.PARENT_ENTITY_ID is null)))
              and   ((A1.HAS_CHILDREN = A2.HAS_CHILDREN) or ((A1.HAS_CHILDREN is null) and (A2.HAS_CHILDREN is null)))
              and   ((A1.HAS_HIERARCHY = A2.HAS_HIERARCHY) or ((A1.HAS_HIERARCHY is null) and (A2.HAS_HIERARCHY is null)))
              and   ((A1.HAS_PEOPLE = A2.HAS_PEOPLE) or ((A1.HAS_PEOPLE is null) and (A2.HAS_PEOPLE is null)))
              and   ((A1.IS_BRANCH = A2.IS_BRANCH) or ((A1.IS_BRANCH is null) and (A2.IS_BRANCH is null)))
              and   ((A1.PARTITION_KEY = A2.PARTITION_KEY) or ((A1.PARTITION_KEY is null) and (A2.PARTITION_KEY is null)))
              and   ((A1.SORT_ORDER = A2.SORT_ORDER) or ((A1.SORT_ORDER is null) and (A2.SORT_ORDER is null)))
              and   ((A1.WEEK_MINUS_1 = A2.WEEK_MINUS_1) or ((A1.WEEK_MINUS_1 is null) and (A2.WEEK_MINUS_1 is null)))
              and   ((A1.WEEK_MINUS_1_FORMAT = A2.WEEK_MINUS_1_FORMAT) or ((A1.WEEK_MINUS_1_FORMAT is null) and (A2.WEEK_MINUS_1_FORMAT is null)))
              and   ((A1.WEEK_MINUS_1_PERF = A2.WEEK_MINUS_1_PERF) or ((A1.WEEK_MINUS_1_PERF is null) and (A2.WEEK_MINUS_1_PERF is null)))
              and   ((A1.WEEK_MINUS_1_PERF_RAG = A2.WEEK_MINUS_1_PERF_RAG) or ((A1.WEEK_MINUS_1_PERF_RAG is null) and (A2.WEEK_MINUS_1_PERF_RAG is null)))
              and   ((A1.WEEK1 = A2.WEEK1) or ((A1.WEEK1 is null) and (A2.WEEK1 is null)))
              and   ((A1.WEEK1_FORMAT = A2.WEEK1_FORMAT) or ((A1.WEEK1_FORMAT is null) and (A2.WEEK1_FORMAT is null)))
              and   ((A1.WEEK1_PERF = A2.WEEK1_PERF) or ((A1.WEEK1_PERF is null) and (A2.WEEK1_PERF is null)))
              and   ((A1.WEEK1_PERF_RAG = A2.WEEK1_PERF_RAG) or ((A1.WEEK1_PERF_RAG is null) and (A2.WEEK1_PERF_RAG is null)))
              and   ((A1.WEEK2 = A2.WEEK2) or ((A1.WEEK2 is null) and (A2.WEEK2 is null)))
              and   ((A1.WEEK2_FORMAT = A2.WEEK2_FORMAT) or ((A1.WEEK2_FORMAT is null) and (A2.WEEK2_FORMAT is null)))
              and   ((A1.WEEK2_PERF = A2.WEEK2_PERF) or ((A1.WEEK2_PERF is null) and (A2.WEEK2_PERF is null)))
              and   ((A1.WEEK2_PERF_RAG = A2.WEEK2_PERF_RAG) or ((A1.WEEK2_PERF_RAG is null) and (A2.WEEK2_PERF_RAG is null)))
              and   ((A1.WEEK3 = A2.WEEK3) or ((A1.WEEK3 is null) and (A2.WEEK3 is null)))
              and   ((A1.WEEK3_FORMAT = A2.WEEK3_FORMAT) or ((A1.WEEK3_FORMAT is null) and (A2.WEEK3_FORMAT is null)))
              and   ((A1.WEEK3_PERF = A2.WEEK3_PERF) or ((A1.WEEK3_PERF is null) and (A2.WEEK3_PERF is null)))
              and   ((A1.WEEK3_PERF_RAG = A2.WEEK3_PERF_RAG) or ((A1.WEEK3_PERF_RAG is null) and (A2.WEEK3_PERF_RAG is null)))
              and   ((A1.WEEK4 = A2.WEEK4) or ((A1.WEEK4 is null) and (A2.WEEK4 is null)))
              and   ((A1.WEEK4_FORMAT = A2.WEEK4_FORMAT) or ((A1.WEEK4_FORMAT is null) and (A2.WEEK4_FORMAT is null)))
              and   ((A1.WEEK4_PERF = A2.WEEK4_PERF) or ((A1.WEEK4_PERF is null) and (A2.WEEK4_PERF is null)))
              and   ((A1.WEEK4_PERF_RAG = A2.WEEK4_PERF_RAG) or ((A1.WEEK4_PERF_RAG is null) and (A2.WEEK4_PERF_RAG is null)))
              and   ((A1.WEEK5 = A2.WEEK5) or ((A1.WEEK5 is null) and (A2.WEEK5 is null)))
              and   ((A1.WEEK5_FORMAT = A2.WEEK5_FORMAT) or ((A1.WEEK5_FORMAT is null) and (A2.WEEK5_FORMAT is null)))
              and   ((A1.WEEK5_PERF = A2.WEEK5_PERF) or ((A1.WEEK5_PERF is null) and (A2.WEEK5_PERF is null)))
              and   ((A1.WEEK5_PERF_RAG = A2.WEEK5_PERF_RAG) or ((A1.WEEK5_PERF_RAG is null) and (A2.WEEK5_PERF_RAG is null)))
              and   ((A1.FIVEWKAVG = A2.FIVEWKAVG) or ((A1.FIVEWKAVG is null) and (A2.FIVEWKAVG is null)))
              and   ((A1.FIVEWKAVG_FORMAT = A2.FIVEWKAVG_FORMAT) or ((A1.FIVEWKAVG_FORMAT is null) and (A2.FIVEWKAVG_FORMAT is null)))
              and   ((A1.FIVEWKAVG_PERF = A2.FIVEWKAVG_PERF) or ((A1.FIVEWKAVG_PERF is null) and (A2.FIVEWKAVG_PERF is null)))
              and   ((A1.FIVEWKAVG_PERF_RAG = A2.FIVEWKAVG_PERF_RAG) or ((A1.FIVEWKAVG_PERF_RAG is null) and (A2.FIVEWKAVG_PERF_RAG is null)))
              and   ((A1.PREV_FIVEWKAVG = A2.PREV_FIVEWKAVG) or ((A1.PREV_FIVEWKAVG is null) and (A2.PREV_FIVEWKAVG is null)))
              and   ((A1.PREV_FIVEWKAVG_FORMAT = A2.PREV_FIVEWKAVG_FORMAT) or ((A1.PREV_FIVEWKAVG_FORMAT is null) and (A2.PREV_FIVEWKAVG_FORMAT is null)))
              and   ((A1.PREV_FIVEWKAVG_PERF = A2.PREV_FIVEWKAVG_PERF) or ((A1.PREV_FIVEWKAVG_PERF is null) and (A2.PREV_FIVEWKAVG_PERF is null)))
              and   ((A1.PREV_FIVEWKAVG_PERF_RAG = A2.PREV_FIVEWKAVG_PERF_RAG) or ((A1.PREV_FIVEWKAVG_PERF_RAG is null) and (A2.PREV_FIVEWKAVG_PERF_RAG is null)))
              and   ((A1.FIVEWKAVG_CHANGE = A2.FIVEWKAVG_CHANGE) or ((A1.FIVEWKAVG_CHANGE is null) and (A2.FIVEWKAVG_CHANGE is null)))
              and   ((A1.FIVEWKAVG_CHANGE_FORMAT = A2.FIVEWKAVG_CHANGE_FORMAT) or ((A1.FIVEWKAVG_CHANGE_FORMAT is null) and (A2.FIVEWKAVG_CHANGE_FORMAT is null)))
              and   ((A1.FIVEWKAVG_CHANGE_PERF = A2.FIVEWKAVG_CHANGE_PERF) or ((A1.FIVEWKAVG_CHANGE_PERF is null) and (A2.FIVEWKAVG_CHANGE_PERF is null)))
              and   ((A1.FIVEWKAVG_CHANGE_PERF_RAG = A2.FIVEWKAVG_CHANGE_PERF_RAG) or ((A1.FIVEWKAVG_CHANGE_PERF_RAG is null) and (A2.FIVEWKAVG_CHANGE_PERF_RAG is null)))
              and   ((A1.MONTH1 = A2.MONTH1) or ((A1.MONTH1 is null) and (A2.MONTH1 is null)))
              and   ((A1.MONTH1_FORMAT = A2.MONTH1_FORMAT) or ((A1.MONTH1_FORMAT is null) and (A2.MONTH1_FORMAT is null)))
              and   ((A1.MONTH1_PERF = A2.MONTH1_PERF) or ((A1.MONTH1_PERF is null) and (A2.MONTH1_PERF is null)))
              and   ((A1.MONTH1_PERF_RAG = A2.MONTH1_PERF_RAG) or ((A1.MONTH1_PERF_RAG is null) and (A2.MONTH1_PERF_RAG is null)))
              and   ((A1.MONTH2 = A2.MONTH2) or ((A1.MONTH2 is null) and (A2.MONTH2 is null)))
              and   ((A1.MONTH2_FORMAT = A2.MONTH2_FORMAT) or ((A1.MONTH2_FORMAT is null) and (A2.MONTH2_FORMAT is null)))
              and   ((A1.MONTH2_PERF = A2.MONTH2_PERF) or ((A1.MONTH2_PERF is null) and (A2.MONTH2_PERF is null)))
              and   ((A1.MONTH2_PERF_RAG = A2.MONTH2_PERF_RAG) or ((A1.MONTH2_PERF_RAG is null) and (A2.MONTH2_PERF_RAG is null)))
              and   ((A1.MONTH3 = A2.MONTH3) or ((A1.MONTH3 is null) and (A2.MONTH3 is null)))
              and   ((A1.MONTH3_FORMAT = A2.MONTH3_FORMAT) or ((A1.MONTH3_FORMAT is null) and (A2.MONTH3_FORMAT is null)))
              and   ((A1.MONTH3_PERF = A2.MONTH3_PERF) or ((A1.MONTH3_PERF is null) and (A2.MONTH3_PERF is null)))
              and   ((A1.MONTH3_PERF_RAG = A2.MONTH3_PERF_RAG) or ((A1.MONTH3_PERF_RAG is null) and (A2.MONTH3_PERF_RAG is null)))
              and   ((A1.MONTH4 = A2.MONTH4) or ((A1.MONTH4 is null) and (A2.MONTH4 is null)))
              and   ((A1.MONTH4_FORMAT = A2.MONTH4_FORMAT) or ((A1.MONTH4_FORMAT is null) and (A2.MONTH4_FORMAT is null)))
              and   ((A1.MONTH4_PERF = A2.MONTH4_PERF) or ((A1.MONTH4_PERF is null) and (A2.MONTH4_PERF is null)))
              and   ((A1.MONTH4_PERF_RAG = A2.MONTH4_PERF_RAG) or ((A1.MONTH4_PERF_RAG is null) and (A2.MONTH4_PERF_RAG is null)))
              and   ((A1.MONTH5 = A2.MONTH5) or ((A1.MONTH5 is null) and (A2.MONTH5 is null)))
              and   ((A1.MONTH5_FORMAT = A2.MONTH5_FORMAT) or ((A1.MONTH5_FORMAT is null) and (A2.MONTH5_FORMAT is null)))
              and   ((A1.MONTH5_PERF = A2.MONTH5_PERF) or ((A1.MONTH5_PERF is null) and (A2.MONTH5_PERF is null)))
              and   ((A1.MONTH5_PERF_RAG = A2.MONTH5_PERF_RAG) or ((A1.MONTH5_PERF_RAG is null) and (A2.MONTH5_PERF_RAG is null)))
              and   ((A1.MONTH6 = A2.MONTH6) or ((A1.MONTH6 is null) and (A2.MONTH6 is null)))
              and   ((A1.MONTH6_FORMAT = A2.MONTH6_FORMAT) or ((A1.MONTH6_FORMAT is null) and (A2.MONTH6_FORMAT is null)))
              and   ((A1.MONTH6_PERF = A2.MONTH6_PERF) or ((A1.MONTH6_PERF is null) and (A2.MONTH6_PERF is null)))
              and   ((A1.MONTH6_PERF_RAG = A2.MONTH6_PERF_RAG) or ((A1.MONTH6_PERF_RAG is null) and (A2.MONTH6_PERF_RAG is null)))
              and   ((A1.QTD = A2.QTD) or ((A1.QTD is null) and (A2.QTD is null)))
              and   ((A1.QTD_FORMAT = A2.QTD_FORMAT) or ((A1.QTD_FORMAT is null) and (A2.QTD_FORMAT is null)))
              and   ((A1.QTD_PERF = A2.QTD_PERF) or ((A1.QTD_PERF is null) and (A2.QTD_PERF is null)))
              and   ((A1.QTD_PERF_RAG = A2.QTD_PERF_RAG) or ((A1.QTD_PERF_RAG is null) and (A2.QTD_PERF_RAG is null)))
              and   ((A1.HTD = A2.HTD) or ((A1.HTD is null) and (A2.HTD is null)))
              and   ((A1.HTD_FORMAT = A2.HTD_FORMAT) or ((A1.HTD_FORMAT is null) and (A2.HTD_FORMAT is null)))
              and   ((A1.HTD_PERF = A2.HTD_PERF) or ((A1.HTD_PERF is null) and (A2.HTD_PERF is null)))
              and   ((A1.HTD_PERF_RAG = A2.HTD_PERF_RAG) or ((A1.HTD_PERF_RAG is null) and (A2.HTD_PERF_RAG is null)))
              and   ((A1.YTD = A2.YTD) or ((A1.YTD is null) and (A2.YTD is null)))
              and   ((A1.YTD_FORMAT = A2.YTD_FORMAT) or ((A1.YTD_FORMAT is null) and (A2.YTD_FORMAT is null)))
              and   ((A1.YTD_PERF = A2.YTD_PERF) or ((A1.YTD_PERF is null) and (A2.YTD_PERF is null)))
              and   ((A1.YTD_PERF_RAG = A2.YTD_PERF_RAG) or ((A1.YTD_PERF_RAG is null) and (A2.YTD_PERF_RAG is null)))
              and   ((A1.PARENT_MEASURE_ID = A2.PARENT_MEASURE_ID) or ((A1.PARENT_MEASURE_ID is null) and (A2.PARENT_MEASURE_ID is null)))
              and   ((A1.MEASURE_TYPE = A2.MEASURE_TYPE) or ((A1.MEASURE_TYPE is null) and (A2.MEASURE_TYPE is null)))
              and   ((A1.MEASURE_GROUP = A2.MEASURE_GROUP) or ((A1.MEASURE_GROUP is null) and (A2.MEASURE_GROUP is null)))
              and   ((A1.PARENT_MEASURE_DESCRIPTION = A2.PARENT_MEASURE_DESCRIPTION) or ((A1.PARENT_MEASURE_DESCRIPTION is null) and (A2.PARENT_MEASURE_DESCRIPTION is null)))
              and   ((A1.LV2_FIVEWKAVG = A2.LV2_FIVEWKAVG) or ((A1.LV2_FIVEWKAVG is null) and (A2.LV2_FIVEWKAVG is null)))
              and   ((A1.LV2_FIVEWKAVG_FORMAT = A2.LV2_FIVEWKAVG_FORMAT) or ((A1.LV2_FIVEWKAVG_FORMAT is null) and (A2.LV2_FIVEWKAVG_FORMAT is null)))
              and   ((A1.LV2_FIVEWKAVG_PERF = A2.LV2_FIVEWKAVG_PERF) or ((A1.LV2_FIVEWKAVG_PERF is null) and (A2.LV2_FIVEWKAVG_PERF is null)))
              and   ((A1.LV2_FIVEWKAVG_PERF_RAG = A2.LV2_FIVEWKAVG_PERF_RAG) or ((A1.LV2_FIVEWKAVG_PERF_RAG is null) and (A2.LV2_FIVEWKAVG_PERF_RAG is null)))
              and   ((A1.LV3_FIVEWKAVG = A2.LV3_FIVEWKAVG) or ((A1.LV3_FIVEWKAVG is null) and (A2.LV3_FIVEWKAVG is null)))
              and   ((A1.LV3_FIVEWKAVG_FORMAT = A2.LV3_FIVEWKAVG_FORMAT) or ((A1.LV3_FIVEWKAVG_FORMAT is null) and (A2.LV3_FIVEWKAVG_FORMAT is null)))
              and   ((A1.LV3_FIVEWKAVG_PERF = A2.LV3_FIVEWKAVG_PERF) or ((A1.LV3_FIVEWKAVG_PERF is null) and (A2.LV3_FIVEWKAVG_PERF is null)))
              and   ((A1.LV3_FIVEWKAVG_PERF_RAG = A2.LV3_FIVEWKAVG_PERF_RAG) or ((A1.LV3_FIVEWKAVG_PERF_RAG is null) and (A2.LV3_FIVEWKAVG_PERF_RAG is null)))
              and   ((A1.LV4_FIVEWKAVG = A2.LV4_FIVEWKAVG) or ((A1.LV4_FIVEWKAVG is null) and (A2.LV4_FIVEWKAVG is null)))
              and   ((A1.LV4_FIVEWKAVG_FORMAT = A2.LV4_FIVEWKAVG_FORMAT) or ((A1.LV4_FIVEWKAVG_FORMAT is null) and (A2.LV4_FIVEWKAVG_FORMAT is null)))
              and   ((A1.LV4_FIVEWKAVG_PERF = A2.LV4_FIVEWKAVG_PERF) or ((A1.LV4_FIVEWKAVG_PERF is null) and (A2.LV4_FIVEWKAVG_PERF is null)))
              and   ((A1.LV4_FIVEWKAVG_PERF_RAG = A2.LV4_FIVEWKAVG_PERF_RAG) or ((A1.LV4_FIVEWKAVG_PERF_RAG is null) and (A2.LV4_FIVEWKAVG_PERF_RAG is null)))
              and   ((A1.LV5_FIVEWKAVG = A2.LV5_FIVEWKAVG) or ((A1.LV5_FIVEWKAVG is null) and (A2.LV5_FIVEWKAVG is null)))
              and   ((A1.LV5_FIVEWKAVG_FORMAT = A2.LV5_FIVEWKAVG_FORMAT) or ((A1.LV5_FIVEWKAVG_FORMAT is null) and (A2.LV5_FIVEWKAVG_FORMAT is null)))
              and   ((A1.LV5_FIVEWKAVG_PERF = A2.LV5_FIVEWKAVG_PERF) or ((A1.LV5_FIVEWKAVG_PERF is null) and (A2.LV5_FIVEWKAVG_PERF is null)))
              and   ((A1.LV5_FIVEWKAVG_PERF_RAG = A2.LV5_FIVEWKAVG_PERF_RAG) or ((A1.LV5_FIVEWKAVG_PERF_RAG is null) and (A2.LV5_FIVEWKAVG_PERF_RAG is null)))
              and   ((A1.LV6_FIVEWKAVG = A2.LV6_FIVEWKAVG) or ((A1.LV6_FIVEWKAVG is null) and (A2.LV6_FIVEWKAVG is null)))
              and   ((A1.LV6_FIVEWKAVG_FORMAT = A2.LV6_FIVEWKAVG_FORMAT) or ((A1.LV6_FIVEWKAVG_FORMAT is null) and (A2.LV6_FIVEWKAVG_FORMAT is null)))
              and   ((A1.LV6_FIVEWKAVG_PERF = A2.LV6_FIVEWKAVG_PERF) or ((A1.LV6_FIVEWKAVG_PERF is null) and (A2.LV6_FIVEWKAVG_PERF is null)))
              and   ((A1.LV6_FIVEWKAVG_PERF_RAG = A2.LV6_FIVEWKAVG_PERF_RAG) or ((A1.LV6_FIVEWKAVG_PERF_RAG is null) and (A2.LV6_FIVEWKAVG_PERF_RAG is null)))
              and   ((A1.LV2_QTD = A2.LV2_QTD) or ((A1.LV2_QTD is null) and (A2.LV2_QTD is null)))
              and   ((A1.LV2_QTD_FORMAT = A2.LV2_QTD_FORMAT) or ((A1.LV2_QTD_FORMAT is null) and (A2.LV2_QTD_FORMAT is null)))
              and   ((A1.LV2_QTD_PERF = A2.LV2_QTD_PERF) or ((A1.LV2_QTD_PERF is null) and (A2.LV2_QTD_PERF is null)))
              and   ((A1.LV2_QTD_PERF_RAG = A2.LV2_QTD_PERF_RAG) or ((A1.LV2_QTD_PERF_RAG is null) and (A2.LV2_QTD_PERF_RAG is null)))
              and   ((A1.LV3_QTD = A2.LV3_QTD) or ((A1.LV3_QTD is null) and (A2.LV3_QTD is null)))
              and   ((A1.LV3_QTD_FORMAT = A2.LV3_QTD_FORMAT) or ((A1.LV3_QTD_FORMAT is null) and (A2.LV3_QTD_FORMAT is null)))
              and   ((A1.LV3_QTD_PERF = A2.LV3_QTD_PERF) or ((A1.LV3_QTD_PERF is null) and (A2.LV3_QTD_PERF is null)))
              and   ((A1.LV3_QTD_PERF_RAG = A2.LV3_QTD_PERF_RAG) or ((A1.LV3_QTD_PERF_RAG is null) and (A2.LV3_QTD_PERF_RAG is null)))
              and   ((A1.LV4_QTD = A2.LV4_QTD) or ((A1.LV4_QTD is null) and (A2.LV4_QTD is null)))
              and   ((A1.LV4_QTD_FORMAT = A2.LV4_QTD_FORMAT) or ((A1.LV4_QTD_FORMAT is null) and (A2.LV4_QTD_FORMAT is null)))
              and   ((A1.LV4_QTD_PERF = A2.LV4_QTD_PERF) or ((A1.LV4_QTD_PERF is null) and (A2.LV4_QTD_PERF is null)))
              and   ((A1.LV4_QTD_PERF_RAG = A2.LV4_QTD_PERF_RAG) or ((A1.LV4_QTD_PERF_RAG is null) and (A2.LV4_QTD_PERF_RAG is null)))
              and   ((A1.LV5_QTD = A2.LV5_QTD) or ((A1.LV5_QTD is null) and (A2.LV5_QTD is null)))
              and   ((A1.LV5_QTD_FORMAT = A2.LV5_QTD_FORMAT) or ((A1.LV5_QTD_FORMAT is null) and (A2.LV5_QTD_FORMAT is null)))
              and   ((A1.LV5_QTD_PERF = A2.LV5_QTD_PERF) or ((A1.LV5_QTD_PERF is null) and (A2.LV5_QTD_PERF is null)))
              and   ((A1.LV5_QTD_PERF_RAG = A2.LV5_QTD_PERF_RAG) or ((A1.LV5_QTD_PERF_RAG is null) and (A2.LV5_QTD_PERF_RAG is null)))
              and   ((A1.LV6_QTD = A2.LV6_QTD) or ((A1.LV6_QTD is null) and (A2.LV6_QTD is null)))
              and   ((A1.LV6_QTD_FORMAT = A2.LV6_QTD_FORMAT) or ((A1.LV6_QTD_FORMAT is null) and (A2.LV6_QTD_FORMAT is null)))
              and   ((A1.LV6_QTD_PERF = A2.LV6_QTD_PERF) or ((A1.LV6_QTD_PERF is null) and (A2.LV6_QTD_PERF is null)))
              and   ((A1.LV6_QTD_PERF_RAG = A2.LV6_QTD_PERF_RAG) or ((A1.LV6_QTD_PERF_RAG is null) and (A2.LV6_QTD_PERF_RAG is null)))
              and   ((A1.LV2_HTD = A2.LV2_HTD) or ((A1.LV2_HTD is null) and (A2.LV2_HTD is null)))
              and   ((A1.LV2_HTD_FORMAT = A2.LV2_HTD_FORMAT) or ((A1.LV2_HTD_FORMAT is null) and (A2.LV2_HTD_FORMAT is null)))
              and   ((A1.LV2_HTD_PERF = A2.LV2_HTD_PERF) or ((A1.LV2_HTD_PERF is null) and (A2.LV2_HTD_PERF is null)))
              and   ((A1.LV2_HTD_PERF_RAG = A2.LV2_HTD_PERF_RAG) or ((A1.LV2_HTD_PERF_RAG is null) and (A2.LV2_HTD_PERF_RAG is null)))
              and   ((A1.LV3_HTD = A2.LV3_HTD) or ((A1.LV3_HTD is null) and (A2.LV3_HTD is null)))
              and   ((A1.LV3_HTD_FORMAT = A2.LV3_HTD_FORMAT) or ((A1.LV3_HTD_FORMAT is null) and (A2.LV3_HTD_FORMAT is null)))
              and   ((A1.LV3_HTD_PERF = A2.LV3_HTD_PERF) or ((A1.LV3_HTD_PERF is null) and (A2.LV3_HTD_PERF is null)))
              and   ((A1.LV3_HTD_PERF_RAG = A2.LV3_HTD_PERF_RAG) or ((A1.LV3_HTD_PERF_RAG is null) and (A2.LV3_HTD_PERF_RAG is null)))
              and   ((A1.LV4_HTD = A2.LV4_HTD) or ((A1.LV4_HTD is null) and (A2.LV4_HTD is null)))
              and   ((A1.LV4_HTD_FORMAT = A2.LV4_HTD_FORMAT) or ((A1.LV4_HTD_FORMAT is null) and (A2.LV4_HTD_FORMAT is null)))
              and   ((A1.LV4_HTD_PERF = A2.LV4_HTD_PERF) or ((A1.LV4_HTD_PERF is null) and (A2.LV4_HTD_PERF is null)))
              and   ((A1.LV4_HTD_PERF_RAG = A2.LV4_HTD_PERF_RAG) or ((A1.LV4_HTD_PERF_RAG is null) and (A2.LV4_HTD_PERF_RAG is null)))
              and   ((A1.LV5_HTD = A2.LV5_HTD) or ((A1.LV5_HTD is null) and (A2.LV5_HTD is null)))
              and   ((A1.LV5_HTD_FORMAT = A2.LV5_HTD_FORMAT) or ((A1.LV5_HTD_FORMAT is null) and (A2.LV5_HTD_FORMAT is null)))
              and   ((A1.LV5_HTD_PERF = A2.LV5_HTD_PERF) or ((A1.LV5_HTD_PERF is null) and (A2.LV5_HTD_PERF is null)))
              and   ((A1.LV5_HTD_PERF_RAG = A2.LV5_HTD_PERF_RAG) or ((A1.LV5_HTD_PERF_RAG is null) and (A2.LV5_HTD_PERF_RAG is null)))
              and   ((A1.LV6_HTD = A2.LV6_HTD) or ((A1.LV6_HTD is null) and (A2.LV6_HTD is null)))
              and   ((A1.LV6_HTD_FORMAT = A2.LV6_HTD_FORMAT) or ((A1.LV6_HTD_FORMAT is null) and (A2.LV6_HTD_FORMAT is null)))
              and   ((A1.LV6_HTD_PERF = A2.LV6_HTD_PERF) or ((A1.LV6_HTD_PERF is null) and (A2.LV6_HTD_PERF is null)))
              and   ((A1.LV6_HTD_PERF_RAG = A2.LV6_HTD_PERF_RAG) or ((A1.LV6_HTD_PERF_RAG is null) and (A2.LV6_HTD_PERF_RAG is null)))
              and   ((A1.LV2_YTD = A2.LV2_YTD) or ((A1.LV2_YTD is null) and (A2.LV2_YTD is null)))
              and   ((A1.LV2_YTD_FORMAT = A2.LV2_YTD_FORMAT) or ((A1.LV2_YTD_FORMAT is null) and (A2.LV2_YTD_FORMAT is null)))
              and   ((A1.LV2_YTD_PERF = A2.LV2_YTD_PERF) or ((A1.LV2_YTD_PERF is null) and (A2.LV2_YTD_PERF is null)))
              and   ((A1.LV2_YTD_PERF_RAG = A2.LV2_YTD_PERF_RAG) or ((A1.LV2_YTD_PERF_RAG is null) and (A2.LV2_YTD_PERF_RAG is null)))
              and   ((A1.LV3_YTD = A2.LV3_YTD) or ((A1.LV3_YTD is null) and (A2.LV3_YTD is null)))
              and   ((A1.LV3_YTD_FORMAT = A2.LV3_YTD_FORMAT) or ((A1.LV3_YTD_FORMAT is null) and (A2.LV3_YTD_FORMAT is null)))
              and   ((A1.LV3_YTD_PERF = A2.LV3_YTD_PERF) or ((A1.LV3_YTD_PERF is null) and (A2.LV3_YTD_PERF is null)))
              and   ((A1.LV3_YTD_PERF_RAG = A2.LV3_YTD_PERF_RAG) or ((A1.LV3_YTD_PERF_RAG is null) and (A2.LV3_YTD_PERF_RAG is null)))
              and   ((A1.LV4_YTD = A2.LV4_YTD) or ((A1.LV4_YTD is null) and (A2.LV4_YTD is null)))
              and   ((A1.LV4_YTD_FORMAT = A2.LV4_YTD_FORMAT) or ((A1.LV4_YTD_FORMAT is null) and (A2.LV4_YTD_FORMAT is null)))
              and   ((A1.LV4_YTD_PERF = A2.LV4_YTD_PERF) or ((A1.LV4_YTD_PERF is null) and (A2.LV4_YTD_PERF is null)))
              and   ((A1.LV4_YTD_PERF_RAG = A2.LV4_YTD_PERF_RAG) or ((A1.LV4_YTD_PERF_RAG is null) and (A2.LV4_YTD_PERF_RAG is null)))
              and   ((A1.LV5_YTD = A2.LV5_YTD) or ((A1.LV5_YTD is null) and (A2.LV5_YTD is null)))
              and   ((A1.LV5_YTD_FORMAT = A2.LV5_YTD_FORMAT) or ((A1.LV5_YTD_FORMAT is null) and (A2.LV5_YTD_FORMAT is null)))
              and   ((A1.LV5_YTD_PERF = A2.LV5_YTD_PERF) or ((A1.LV5_YTD_PERF is null) and (A2.LV5_YTD_PERF is null)))
              and   ((A1.LV5_YTD_PERF_RAG = A2.LV5_YTD_PERF_RAG) or ((A1.LV5_YTD_PERF_RAG is null) and (A2.LV5_YTD_PERF_RAG is null)))
              and   ((A1.LV6_YTD = A2.LV6_YTD) or ((A1.LV6_YTD is null) and (A2.LV6_YTD is null)))
              and   ((A1.LV6_YTD_FORMAT = A2.LV6_YTD_FORMAT) or ((A1.LV6_YTD_FORMAT is null) and (A2.LV6_YTD_FORMAT is null)))
              and   ((A1.LV6_YTD_PERF = A2.LV6_YTD_PERF) or ((A1.LV6_YTD_PERF is null) and (A2.LV6_YTD_PERF is null)))
              and   ((A1.LV6_YTD_PERF_RAG = A2.LV6_YTD_PERF_RAG) or ((A1.LV6_YTD_PERF_RAG is null) and (A2.LV6_YTD_PERF_RAG is null)))
              and   ((A1.DIF_FROM_PEER_FIVEWKAVG = A2.DIF_FROM_PEER_FIVEWKAVG) or ((A1.DIF_FROM_PEER_FIVEWKAVG is null) and (A2.DIF_FROM_PEER_FIVEWKAVG is null)))
              and   ((A1.DIF_FROM_PEER_FIVEWKAVG_FORMAT = A2.DIF_FROM_PEER_FIVEWKAVG_FORMAT) or ((A1.DIF_FROM_PEER_FIVEWKAVG_FORMAT is null) and (A2.DIF_FROM_PEER_FIVEWKAVG_FORMAT is null)))
              and   ((A1.DIF_FROM_PEER_FIVEWKAVG_PERF = A2.DIF_FROM_PEER_FIVEWKAVG_PERF) or ((A1.DIF_FROM_PEER_FIVEWKAVG_PERF is null) and (A2.DIF_FROM_PEER_FIVEWKAVG_PERF is null)))
              and   ((A1.DIF_FROM_PEER_FIVEWK_PERF_RAG = A2.DIF_FROM_PEER_FIVEWK_PERF_RAG) or ((A1.DIF_FROM_PEER_FIVEWK_PERF_RAG is null) and (A2.DIF_FROM_PEER_FIVEWK_PERF_RAG is null)))
              and   ((A1.DIF_FROM_PEER_QTD = A2.DIF_FROM_PEER_QTD) or ((A1.DIF_FROM_PEER_QTD is null) and (A2.DIF_FROM_PEER_QTD is null)))
              and   ((A1.DIF_FROM_PEER_QTD_FORMAT = A2.DIF_FROM_PEER_QTD_FORMAT) or ((A1.DIF_FROM_PEER_QTD_FORMAT is null) and (A2.DIF_FROM_PEER_QTD_FORMAT is null)))
              and   ((A1.DIF_FROM_PEER_QTD_PERF = A2.DIF_FROM_PEER_QTD_PERF) or ((A1.DIF_FROM_PEER_QTD_PERF is null) and (A2.DIF_FROM_PEER_QTD_PERF is null)))
              and   ((A1.DIF_FROM_PEER_QTD_PERF_RAG = A2.DIF_FROM_PEER_QTD_PERF_RAG) or ((A1.DIF_FROM_PEER_QTD_PERF_RAG is null) and (A2.DIF_FROM_PEER_QTD_PERF_RAG is null)))
              and   ((A1.DIF_FROM_PEER_HTD = A2.DIF_FROM_PEER_HTD) or ((A1.DIF_FROM_PEER_HTD is null) and (A2.DIF_FROM_PEER_HTD is null)))
              and   ((A1.DIF_FROM_PEER_HTD_FORMAT = A2.DIF_FROM_PEER_HTD_FORMAT) or ((A1.DIF_FROM_PEER_HTD_FORMAT is null) and (A2.DIF_FROM_PEER_HTD_FORMAT is null)))
              and   ((A1.DIF_FROM_PEER_HTD_PERF = A2.DIF_FROM_PEER_HTD_PERF) or ((A1.DIF_FROM_PEER_HTD_PERF is null) and (A2.DIF_FROM_PEER_HTD_PERF is null)))
              and   ((A1.DIF_FROM_PEER_HTD_PERF_RAG = A2.DIF_FROM_PEER_HTD_PERF_RAG) or ((A1.DIF_FROM_PEER_HTD_PERF_RAG is null) and (A2.DIF_FROM_PEER_HTD_PERF_RAG is null)))
              and   ((A1.DIF_FROM_PEER_YTD = A2.DIF_FROM_PEER_YTD) or ((A1.DIF_FROM_PEER_YTD is null) and (A2.DIF_FROM_PEER_YTD is null)))
              and   ((A1.DIF_FROM_PEER_YTD_FORMAT = A2.DIF_FROM_PEER_YTD_FORMAT) or ((A1.DIF_FROM_PEER_YTD_FORMAT is null) and (A2.DIF_FROM_PEER_YTD_FORMAT is null)))
              and   ((A1.DIF_FROM_PEER_YTD_PERF = A2.DIF_FROM_PEER_YTD_PERF) or ((A1.DIF_FROM_PEER_YTD_PERF is null) and (A2.DIF_FROM_PEER_YTD_PERF is null)))
              and   ((A1.DIF_FROM_PEER_YTD_PERF_RAG = A2.DIF_FROM_PEER_YTD_PERF_RAG) or ((A1.DIF_FROM_PEER_YTD_PERF_RAG is null) and (A2.DIF_FROM_PEER_YTD_PERF_RAG is null))))

但它完全永远地完成,我现在已经取消它,希望有人能够找到更快的方法,如果可能的话。

作为参考,它包含大约130万行,正好有一半是重复的。

感谢。

2 个答案:

答案 0 :(得分:3)

尝试使用group by

执行此操作
delete from MMI_OWNER.IMART_TTI_RET_MY_CUSTOMERS A1
    where a1.rowid not in (select min(a2.rowid)
                           from MMI_OWNER.IMART_TTI_RET_MY_CUSTOMERS A2
                           group by . . .
                          );
但是,我应该注意,删除表中一半的行可能是一个很大的操作。你可能会考虑:

create table t as
    select . . .
    from (select t.*, row_number() over (partition by . . . order by rowid) as seqnum
          from t
         ) t
    where seqnum = 1;

truncate table MMI_OWNER.IMART_TTI_RET_MY_CUSTOMERS;

insert into MMI_OWNER.IMART_TTI_RET_MY_CUSTOMERS(. . . )
    select . . .
    from t;

答案 1 :(得分:0)

如果您有重复项,那么您的代码将删除这两个版本。

我会考虑你是否可以使用散列机制来加快速度。

DELETE
from MMI_OWNER.IMART_TTI_RET_MY_CUSTOMERS A1
where exists (Select 'x' from MMI_OWNER.IMART_TTI_RET_MY_CUSTOMERS A2
              where A1.ROWID < A2.ROWID
              and   ORA_HASH(
                                A1.MEASURE_ID
                        ||'#'|| A1.MEASURE_NAME
                        ||'#'|| A1.MEASURE_DESCRIPTION ... etc) =
                    ORA_HASH(
                                A2.MEASURE_ID
                        ||'#'|| A2.MEASURE_NAME
                        ||'#'|| A2.MEASURE_DESCRIPTION ... etc))

换句话说,生成由一些不太可能的字符分隔的列值的唯一散列,并使用它来检查等价。

由于统计上可能存在哈希冲突,这不是一种100%万无一失的方法。