Elgg/Elgg — pull request #7670 by mrclay (2014-12-13 06:19:25+00:00)
Title: perf(river): reduces queries to list responses in the river

Rather than always COUNT() responses first, we simply fetch one more than we
need. In case we get back 1, 2, or 3 responses we don’t need a separate
query to get the count. At the worst case this simply converts 0-returning
COUNT queries to empty-returning fetch queries.

This also fixes the order of discussion replies in the river.

Fixes #7664, #7668