Nick Trainor <nick(dot)trainor(at)trainorthornton(dot)co(dot)uk> writes:
> What am I missing here?
The ORDER BY query has to evaluate the function at *every* row of the
table before it can sort. The other query was only evaluating the
function at twenty rows.
regards, tom lane