When I try to do something like
SELECT Max(ObjectId) FROM Objects;
I see that in terms of explanation this is done by doing a sort. Now sorting (which, it seems to me, will require something in complexity O(nlogn)) should be much more expensive than just scanning each line and remembering the maximum value (which can be done in O(n)).
Am I missing something? Is the oracle really doing sorting, or is the explanation plan just using the "sort" description to describe a simple scan of all the values ββin the ObjectId column? If the oracle really does the "real sort", is there a good reason for this that I am missing?
Thanks in advance!
source
share