On Monday 20 of June 2005 00:12, you wrote: > I have such a statement: > select * from (subquery1) as foo, (subquery2) as bar; > Both subqueries are reasonably fast (<0.5s) and generate results that have > several (<10) rows but the whole query takes forever to execute. Ok, postgresql wanted to be smarter that myself. It expanded the query instead of executing them in order given by parenthesis. The solution (or just workaround?) was to set two variables: from_collapse_limit = 1 join_collapse_limit = 1 Tomek ---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match