Earlier quoted context omitted.
I'd like to know more about your case, because my own experience is that ordering by ts_rank causes a big slowdown. PostgreSQL documentation says: "Ranking can be expensive since it requires consulting the tsvector of each matching document, which can be I/O bound and therefore slow. Unfortunately, it is almost impossible to avoid since practical queries often result in large numbers of matches." Some PostgreSQL deve…
Ordering can get expensive no matter what just base on how many things you're actually sorting. Ideally, if you can find a way to limit the size of the data set before the ranking sort you'll see a big improvement.
But it looks like it could be possible to massively improve ranking performance by storing all necessary information directly in the GIN index, as proposed here:
https://wiki.postgresql.org/images/2/25/Full-text_search_in_...