Michael Contzen <mcontzen(at)dohle(dot)com> writes:
> Does postgres sort the whole table without projection to one column an
> performs a unique on this whole table?
No, it only sorts the column(s) being selected.
My guess is that your performance problem comes from using "numeric"
datatype. Consider int or bigint instead of numeric(10,0).
regards, tom lane