I have this query, but its so slow... I think the NOT IN function is the part slowing me down
SELECT ID
FROM APPL
WHERE TRIM(RCNL_ID) = XXX.20191102' AND ID NOT IN
(
SELECT ID
FROM HIST
WHERE SUBSTR(ID, 12, 1) = '9' AND TRAN_STATUS = 'REOK'
)
ORDER BY ID;
It takes a while to run like 50-60 second is there a clever way to rewrite this so its faster?
This is in Oracle Sql Developer
Try using a materialised view(mv) or an index..? https://oracle-base.com/articles/misc/materialized-views
CREATE MATERIALIZED VIEW your_mv
PCTFREE 5
BUILD IMMEDIATE
REFRESH FORCE
ENABLE QUERY REWRITE
as
SELECT ID
FROM APPL
WHERE TRIM(RCNL_ID) = XXX.20191102' AND ID NOT IN
(
SELECT ID
FROM HIST
WHERE SUBSTR(ID, 12, 1) = '9' AND TRAN_STATUS = 'REOK'
)
ORDER BY ID;
Try using function based indexes
http://www.dba-oracle.com/t_regular_expressions_tuning_index.htm
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.