I rewrote it using lead and lag but the response times and autotrace stats were almost identical:
Plan is similar:Code:select rowid, (case when leader is not null and lagger is null then 1 else 2 end) as error_bit_id from (select rowid, lead(rowid) over (PARTITION BY NVL(DEAL_ID, '~NVL'),NVL(LEG_TYPE_CD, '~NVL') ORDER BY SRC_SYS_FEED_ROW_ID DESC, SCHEDULE_ID DESC) as leader, lag(rowid) over (PARTITION BY NVL(DEAL_ID, '~NVL'),NVL(LEG_TYPE_CD, '~NVL') ORDER BY SRC_SYS_FEED_ROW_ID DESC, SCHEDULE_ID DESC) as lagger from schedule WHERE BUSINESS_DATE = :p_business_date and SRC_SYS_FEED_ID = :p_src_sys_feed_id and BITAND(ROW_ERROR_CD, 3) = 0) where leader is not null or lagger is not null
Code:Operation Object Name Rows Bytes Cost Object Node In/Out PStart PStop SELECT STATEMENT Hint=CHOOSE 5 K 3373 VIEW 5 K 112 K 3373 WINDOW SORT 5 K 304 K 3373 PARTITION RANGE SINGLE KEY KEY TABLE ACCESS FULL SCHEDULE 5 K 304 K 3319 KEY KEY




Reply With Quote