Lincoln Yeoh <lyeoh(at)pop(dot)jaring(dot)my> writes:
> Which would be better to do, max() or select .. order by limit 1?
If there's an index that the ORDER BY can key on, the second will be
much better. If there's not, I'd go with the max(); you don't really
want a complete sort operation.
> Is 7.1 much better than 7.0.3 in doing the "limit 1"? I see that their
> EXPLAINs are different - 7.1 has a limit cost.
Should be about the same. The appearance of a Limit plan node in 7.1
is an implementation change that was necessary to support LIMIT clauses
in subqueries, but it shouldn't make any noticeable performance
difference for top-level limits.
regards, tom lane