If I make the following query in postgres, is it calculating the ts_rank twice or just once? If it is calculating it twice, is it possible to make it calculate it only once?
SELECT id, name, "createdAt", price, ts_rank(document, to_tsquery(:query)) AS rank
FROM search_index
WHERE document @@ to_tsquery(:query)
ORDER BY ts_rank(document, to_tsquery(:query)) DESC;