2016-07-11 5 views
0

Итак, у меня есть идеальные обманы в таблице, которые я снял с производства на прошлой неделе (в конце дня) Я уверен, что я не поставил галочку на первый усеченный ящик в TOAD, и у меня есть приятная куча обманов в моем столе. Я бег следующего запроса:Oracle Deduping занимает слишком много времени

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)))) 

, но он принимает абсолютно навсегда до конца, я отменил его сейчас в надежде, что кто-то может найти более быстрый способ сделать это, если это возможно.

Для справки, он содержит около 1,3 миллиона строк, ровно половину дубликатов.

Спасибо.

ответ

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; 
+0

Привет, Гордон, я получаю следующее: ORA-01427: однострочный подзапрос возвращает более одной строки из группы по функции. Временная таблица не жизнеспособна, так как в нашем тестовом env недостаточно места. – Elrodge

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% надежный способ из-за статистически возможного столкновения хэшей.