MIN(DISTINCT X)

What is doing the MIN(DISTINCT X) call? Basically, every distinct value of X is passed to the MIN function. Well, it is probably of very little interest as the MIN function is very fast and processing less rows than MIN(X) should not boost the performance because of the overhead of sorting distinct values.

However, if you write your own aggregate, distinct may be interesting!

of course Gary, thanks for making this clear, my point was using DISTINCT to achieve a better performance when ALL and DISTINCT are equivalent, as for min, MIN(ALL X) is always the same as MIN(DISTINCT X)

You may then wonder why MIN and MAX accept DISTINCT but MEDIAN does not…