Tom Lane wrote:
Markus Schaber <[EMAIL PROTECTED]> writes:
So, now my question is, why does the query optimizer not recognize that
it can throw away those "non-unique" Sort/Unique passes?

Because the issue doesn't come up often enough to justify expending cycles to check for it.

How many cycles are we really talking about, though? I have a patch which I'll send along in a few days which implements a similar optimization: if a subselect is referenced by EXISTS or IN, we can discard DISTINCT and ORDER BY clauses in the subquery (actually, we can't discard ORDER BY in the case of IN if LIMIT is also specified, but the point remains). It's very cheap computationally for the planner to do this simplification, and I'd imagine doing the equivalent simplifications for UNION is similarly cheap.


While I understand what you're saying WRT to it being a silly query, in the real world people make mistakes...

-Neil

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Reply via email to