AutocompleteController#users.json is dreadfully slow (because of bad queries)

Summary

Screen_Shot_2017-01-23_at_15.02.13

Steps to reproduce

Just use the endpoint without filtering by one project according to monitoring

Expected behavior

To reply under 100ms in the p99

Actual behavior

The mean is at 1.6s, the p95 is at 4.11s and the p99 is at 4.26s

Relevant logs and/or screenshots

It's up in the summary, also check the monitoring URL to get a better feel of where the problem is coming from.

cc/ @DouweM @smcgivern because I don't know who owns this endpoint.

cc/ @yorickpeterse because he cares about performance and databases.