My understanding is that relational tables aren't ordered.
I also understand that each step, or phase, of the query execution returns a "virtual table" which is passed as input to the next phase.
But if tables are never actually ordered, what's happening during/after the ORDER BY phase?
I'm just trying to understand what might happen with a query like this:
SELECT col1, col2
FROM mytable
ORDER BY col1
LIMIT 1;
Edit:
To clarify. I know what the query above outputs. I'm trying to better understand each phase/step of the underlying execution.
The (logical) order of execution (EDIT: different from the physical execution) for the above query would be:
FROM
SELECT
ORDER BY
LIMIT
I'm trying to understand what's going on during the ORDER BY phase. My understanding is that a virtual table is passed from the SELECT phase to the ORDER BY phase (in this case, a table with col1 and col2, but I don't know what's being returned by ORDER BY and subsequently passed to LIMIT.