Why is Max () creating an order in terms of explanation?

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!

+1
source share
1

Objects, . , ObjectId. FULL SCAN (MIN/MAX) , , . , MIN/MAX.

O (log n) ( ).

:

ObjectId, SORT AGGREGATE . , . . , , , O (n).

Oracle, , O (n) .

+5

All Articles