Mark Hills <mark@xxxxxxxxxxx> writes: > I hadn't realised that sub-queries restrict the planner so much. Although > at some point I've picked up a habit of avoiding them, presumably for this > reason. > If you have time to explain, I'd be interested in a suggestion for any > change to the planner that could make a small contribution towards > improving this. eg. a small project that could get me into the planner > code. Well, if it were easy to do, we'd probably have done it already ... Plain subqueries might perhaps be turned into joins (with special join types no doubt), but I'm not sure what we'd do about subqueries with grouping or aggregation, as your examples had. There was some talk a month or three back about allowing such subqueries to have parameterized paths a la the recently-added parameterized path mechanism, but it didn't get further than idle speculation. regards, tom lane -- Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance