test2=# EXPLAIN SELECT * FROM (SELECT * FROM t ORDER BY a) foo ORDER BY a, b; QUERY PLAN ------------------------------------------------------------------------ Incremental Sort (cost=147027.04..269419.25 rows=1000000 width=20) Sort Key: t.a, t.b Presorted Key: t.a -> Sort (cost=136537.84..139037.84 rows=1000000 width=20) Sort Key: t.a -> Seq Scan on t (cost=0.00..16370.00 rows=1000000 width=20) (6 rows)