In my RoR app, I have a query that could return anywhere 0 to 1000000 results, that I'm limiting to 16 and providing pagination for:
find(:all, :conditions => conditions, :limit => limit, :offset => offset)
I'd like to be able to tell the user how many results they're looking at vs. the total amount of results. Something like "Showing 16 of 500". What is the best way to get the total amount of rows without doing an non-limited query, which would surely be slow in the case of a large result set? I'd also like to remain database agnostic.