Hi Beth,

"Beth Jen" <[EMAIL PROTECTED]> writes:
> Right now, the distinct clause adds its targets to the sort clause list when
> it is parsed.

Yeah, the DISTINCT/DISTINCT ON implementation is currently rather
tightly tied to sorting :-(.  This is ancient code and badly in need of
redesign, but it's not clear how to clean it up without breaking the
expected behavior of DISTINCT ON.  There may not be any alternative
except to divorce DISTINCT from DISTINCT ON and make them two separate
code paths, but that's hardly appealing.  On the other side of the coin,
there's the analogy to GROUP BY that Greg points out --- there's some
duplicated functionality there, but again it doesn't carry over to

It might work to have parse analysis not add the DISTINCT list to the
ORDER BY list, but instead store them as separate Query fields, and have
the planner add DISTINCT to ORDER BY if it decides to use sort-based
distinct-ing.  I'm not sure if there's any good way to merge all three

                        regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not

Reply via email to