SELECT t1.A A,
t1.B B,
t1.C C,
t1.D D,
t1.E E,
t1.F F,
GET_TIME(t1.G, t1.H) GETTIME
FROM XXX.TABLE1 t1,
YYY.TABLE2 t2
WHERE t1.I = 'BRI'
AND t2.A = 10
AND t2.B = 'SYSTEM'
AND t1.J = t2.C
When i execute this query, it gives me a result in 10 seconds (total rows = 9,80,00,000).
But when i tried to use ROW_NUMER() like below, it takes more than 30 minutes....
SELECT A,B,C,D,E,F, GETTIME
ROW_NUMBER() OVER (PARTITION BY B,GETTIME ORDER BY C,A) C_NUM
ROW_NUMBER() OVER (PARTITION BY B,GETTIME ORDER BY D,A) D_NUM
FROM
(
SELECT t1.A A,
t1.B B,
t1.C C,
t1.D D,
t1.E E,
t1.F F,
GET_TIME(t1.G, t1.H) GETTIME
FROM XXX.TABLE1 t1,
YYY.TABLE2 t2
WHERE t1.I = 'BRI'
AND t2.A = 10
AND t2.B = 'SYSTEM'
AND t1.J = t2.C
)
Can someone help me how to tune this query while using ROW_NUMBER() function. I have used inline view, because i do not want to use GET_TIME user-defined function again in ROW_NUMBER() function.