Interesting thing, obvious in retrospect, but absolutely unexpected just a week ago: we were doing selects with "distinct on" from pg. This week we've cleaned duplicates from the db and distinct is now unnecessary. This lowered 99% API response time from 2.2s to 0.2s. Median time is almost the same, but the long tail is now much shorter. :)