How to optimize ORACLE query?

0

I need to optimize queries so that having a better performance when looking for the data is taking me too long an example

This is the query I'm using the ORACLE database

SELECT 
SM_ID,
ORIGINAL_ADDRESS,
DESTINATION_ADDRESS,
SUBMISSION_TIME,
FINAL_TIME,
SM_STATUS,
ERROR_CODE,
ORG_ACCOUNT,
DEST_ACCOUNT,
MO_MSC_ADDR,
MT_MSC_ADDR
FROM SMS_DATA_SMC
WHERE TRUNC(SUBMISSION_TIME) = TO_DATE('22/11/2018', 'DD-MM-YYYY') 
AND MO_MSC_ADDR is not null
AND MO_MSC_ADDR NOT LIKE '569%' AND FINAL_TIME IS NOT NULL
ORDER BY SM_ID
    
asked by Juan Perez 23.11.2018 в 13:01
source

1 answer

0

Try with

SELECT 
SM_ID,
ORIGINAL_ADDRESS,
DESTINATION_ADDRESS,
SUBMISSION_TIME,
FINAL_TIME,
SM_STATUS,
ERROR_CODE,
ORG_ACCOUNT,
DEST_ACCOUNT,
MO_MSC_ADDR,
MT_MSC_ADDR
FROM SMS_DATA_SMC
WHERE 
FINAL_TIME IS NOT NULL
AND MO_MSC_ADDR is not null
AND MO_MSC_ADDR NOT LIKE '569%' 
AND TRUNC(SUBMISSION_TIME) = TO_DATE('22/11/2018', 'DD-MM-YYYY') 
ORDER BY SM_ID

This is filtered first to eliminate fields with a direct comparison, and then the part that involves calls to functions is already compared.

Maybe you should create indexes so you do not have to read the whole table to filter it.

    
answered by 23.11.2018 в 13:11