[Issue 2112473] Speeding up aggregation by changing LEFT OUTER JOIN to JOIN and adding LIMIT to some queries

Amazingly, these minor changes dramatically improve some frequently used
query plans and prevent odd data sets with lots of matches from having too much
of a negative affect on performance.

Change-Id: I13b3e0df0f1d4f37c04f60907ff201797096d0e3
2 files changed