On Mon, 8 Nov 2004, Morten K. Poulsen wrote: > Please let me know if this is not the list to ask this kind of question. > > I am trying to optimize a query that joins two relatively large (750000 rows > in > each) tables. If I do it using a subselect, I can "force" the planner to > choose > the fastest path. Now, my question is: > > If I have a subselect with an ORDER BY, and I LEFT JOIN the result with the > other table, is the order maintained? Or is PostgreSQL free to return the rows > in any order, after the join?
AFAIK, you have no guarantees as to the output order unless you have another order by. The join may destroy the ordering, so even if you get the ordering you want right now, you shouldn't rely on it. ---------------------------(end of broadcast)--------------------------- TIP 7: don't forget to increase your free space map settings