Found out today how to do a PostgreSQL query with a limit (and offset) while still getting the total number of rows that would have matched without the limit.
SELECT col1, col2, COUNT(*) [COLOR="#B22222"]OVER()[/COLOR] FROM table1 LIMIT 10 OFFSET 0;
The OVER() (which can have a bunch of parameters I didn't need) causes the COUNT() aggregate function to apply to all matching results before the LIMIT is applied. This kept me from having to do a separate query to get the total matches to be used for the pagination function.