Hi,
I would like to optimize the performance of the below query,
SELECT TO_NUMBER(TO_CHAR(date_col, 'iyyy')) AS paid_in_year,
TO_NUMBER(TO_CHAR(date_col, 'ww')) AS paid_in_week,
EXTRACT(DAY FROM ((date_col - date_col2) DAY(4) TO SECOND)) AS input_to_paid_days,
COUNT(id) AS ID,
date_col2 as PAID_DATE
FROM big_table
WHERE extract(year from date_col2) >= extract(year from sysdate) - 2
AND col1 != 'NWLK'
AND col2 = '02'
GROUP BY TO_NUMBER(TO_CHAR(date_col, 'iyyy')),
TO_NUMBER(TO_CHAR(date_col, 'ww')),
EXTRACT(DAY FROM ((date_col - date_col2) DAY(4) TO SECOND)),date_col2
The table referred in the query is a very huge table. Please help me in fixing this.
I understand that it has got more oracle functions in it and and a group by that makes the query to run slower.
But please assist in restructuring the SQL. This is my base query and I have even more logical calculations run over it to get the final result.
Thanks.