"Jim C. Nasby" <decibel(at)decibel(dot)org> writes:
> Actually, the planner (at least in 7.4) isn't smart enough to consider
> if the sort would fit in memory or not.
Really? Have you read cost_sort()?
It's certainly possible that the calculation is all wet, but to claim
that the issue is not considered is just wrong.
regards, tom lane