T E Schmitz <[EMAIL PROTECTED]> writes: > As far as I can see (via EXPLAIN), both DISTINCT and GROUP BY will lead > to a sequentail scan. Is that correct?
I'm not sure why you expect something different. The query requires visiting every row of the table in any case --- else it might miss values that occur only once --- therefore a seqscan is most efficient. The planner will consider plans that involve an indexscan, but only as a substitute for doing an explicit sort before a uniq-style grouping step. Generally the explicit sort will win that comparison. And a hash grouping step probably dominates them both. regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])