I am working with an Oracle DB remotely and need to find the max value of a column for which I ran this query:
SELECT MAX(col1) FROM table1;
The above query always times out while the following one, surprisingly, works:
SELECT col1 FROM table1 WHERE ROWNUM < 2 ORDER BY col1 DESC;
I am unable to understand why this is happening, as both queries are semantically identical. What's more, the aggregate functions are supposed to be optimized for this kind of thing.
Any clarification on this would be appreciated.