Glyn Astill <glynastill@xxxxxxxxxxx> writes: > Does anyone know how I can change what I'm doing to get pgsql to pick a better plan? You've provided no evidence that this is a bad plan. In particular, the plan you seem to think would be better would involve an estimated 153 iterations of the cost-15071 hash aggregation, which simple arithmetic shows is more expensive than the plan it did choose. regards, tom lane -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general