elasticsearch/elasticsearch — pull request #6520 by rmuir (2014-06-16 18:48:53+00:00)
Title: Use ordinals for comparison in GlobalOrdinalsStringTermsAggregator.build...

...Aggregation. Closes #6518

I used Martijn's benchmark to measure terms agg at different cardinality, I'm sure its not a perfect benchmark but it demonstrates the issue, in the current code the term lookups start to dominate the total time:

|cardinality|avg ms (master)|avg ms (patch)|
|-----|----------|----------|
1M|4751ms|4380ms
5M|5803ms|5030ms
10M|6421ms|5079ms
25M|8725ms|5992ms
50M|11829ms|6179ms
100M|20266ms|7064ms