Elgg/Elgg — pull request #7338 by mrclay (2014-10-20 03:04:36+00:00)
Title: perf(sql): allows removing DISTINCT from some MySQL queries

(freshly rebased for 1.x - @Srokap give this a look)

We add the "distinct" option to a few query functions to allow devs to
remove DISTINCT clauses from queries where they are unnecessary and worsen
performance. We also set the option in some core queries where it's unlikely
to cause trouble.

Fixes #4594