Reputation: 15809
When doing a Postgres full text search, is it possible to return the top 10 relevance-ranked rows (using LIMIT), but also get the total number of rows found?
I'd like to implement a Google-like message in my search results: "Showing rows 1 to 10 of 1000 results"
Upvotes: 0
Views: 481
Reputation: 23586
You can use window functions for that:
SELECT
*,
COUNT(*) OVER ()
FROM table
LIMIT 10
Upvotes: 2