Is there a way to optimize following query? It returns the right records but takes more than a minute to execute.
select STATUS, SUBNO, TRUNC(TRSF_DATE) TRSF_DATE
from
(
select STATUS, SUBNO, TRUNC(TRSF_DATE) TRSF_DATE
from tbl where
trsf_date is not null and
contrno in ('8', '8A', '8B', '8C', '8D', '8E', '8PH3A', '8PH3B', '8PH3C', '8PHD')
)
where trsf_date = to_date('5/21/2011', 'mm/dd/yyyy')**
The requirements are to return records where:
- contrno in ('8','8A','8B','8C','8D','8E','8PH3A','8PH3B','8PH3C','8PHD')
- trsf_date = some specific date
Note that the trsf_date column is NULLable and I have to use trsf_date in the WHERE clause. That is why I used an inner query to first fetch NOT NULL rows, then select rows from that. Otherwise the query will get stuck and not return any rows.