Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Tuning having MAX function

Status
Not open for further replies.

siraj777

Programmer
Aug 22, 2002
27
IN
SELECT quarter
FROM rcqtr
WHERE rcqtr_num = ( SELECT MAX(rcqtr_num) FROM rcprod11 )

rcprod11 table having 400,000 rows.
rcqtr table have around 1000 rows.

The above query is taking 30 seconds. Any ideas to tune it?
 
Dima, Would that be a function based index? How about an additional index on rcqtr.quarter , rcqtr.rcqtr_num ?


Would something like
SELECT a.quarter, max(b.rcqtr_num) over (partition by b.rcqtr_num) FROM rcqtr A, rcprod11 B
WHERE a.rcqtr_num = b.rcqtr_num
 
dbtoo2001, did you mean FFS? It may depends on, because the size of compound index sometimes may not fit into memory thus it would be faster to perform a set of "in memory" operations instead of one, even easier, but "in swap". As for windowing, yes, this is the best way IMHO, but in 8i it has some limitations (and workarounds though).
As for this specific case with 30 sec for 400K rows - the plan should be ugly indeed :)

Regards, Dima
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top