Martijn van Oosterhout <kleptog@xxxxxxxxx> writes: > A random thought: Is there not some way of representing this difference > in the planner? It's not so much that we have no way to represent the ordering, as that the planner currently doesn't have any place in its conceptual model for costs incurred outside the "plan tree". In this example we consider only the costs of the SELECT part, not costs of inserting the resulting rows someplace. Up to now we've always assumed that such costs could be ignored because they'd be about the same for every valid plan for a given query. This is the first example I can remember seeing in which (a) that is not true, and (b) the effect might conceivably be within the planner's ability to estimate costs for. regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster