Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Tune the query with ROW_NUMBER() Function

AceNoviceMar 29 2010 — edited Mar 31 2010
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.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 28 2010
Added on Mar 29 2010
18 comments
8,939 views