On Tue, 2009-05-19 at 13:01 +0100, Matthew Wakeling wrote: > That leads me on to another topic. Consider the query: > > SELECT * FROM table ORDER BY a, b > > where the column "a" is declared UNIQUE and has an index. Does Postgres > eliminate "b" from the ORDER BY, and therefore allow fetching without > sorting from the index? No, because we don't use unique constraints much at all to infer things. > Or how about this query: > > SELECT * FROM table1, table2 WHERE table1.fk = table2.id ORDER BY > table1.id, table2.id > > where both "id" columns are UNIQUE with an index. Do we eliminate > "table2.id" from the ORDER BY in this case? Yes, that is eliminated via equivalence classes. -- Simon Riggs www.2ndQuadrant.com PostgreSQL Training, Services and Support -- Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance