Hans-Jürgen Schönig <postgres@cybertec.at> writes:
> I was wondering whether it is possible to teach the planner to handle
> DISTINCT in a more efficient way:
Probably (although the interactions with ORDER BY might be tricky).
No one has touched that part of the planner in a very long time.
regards, tom lane