finding maximum value without max function:peformance??

From: Mahesh Vallampati <m0v5533_at_tamsun.tamu.edu>
Date: 14 Feb 1994 20:27:57 -0600
Message-ID: <2jpbvd$bra_at_tamsun.tamu.edu>


Hie folks,
This query below will select the maximum value in a table without using the max function.

val1 and val2 are of the datatype number.

SELECT VAL1,VAL2 FROM TEMP
MINUS
SELECT TEMP.VAL1,TEMP.VAL2 FROM TEMP,TEMP TEMP1 WHERE TEMP.VAL2<TEMP1.VAL2;

This query is pretty slow.Any suggestions as to how to improve the performance of the query? what sort of an index would one build for these sort of queries?

Not that i am not aware of the max function. I timed this query in Oracle Version 6.0 with 1000 rows(or shall we call them tuples:-) ) and it is real slow.

Any suggestions would be most welcome.

Mahesh Vallampati
M.S. In EE
Dept.of Electrical Engineering,
Texas A & M University.
Ph:(409)862-1070
/* Thy Shall Inherit and Distribute */ Received on Tue Feb 15 1994 - 03:27:57 CET

Original text of this message