count() question - Mailing list pgsql-sql

From Mitch Vincent
Subject count() question
Date
Msg-id 021101bf490b$d43b7ec0$0300000a@doot.org
Whole thread Raw
Responses Re: [SQL] count() question
List pgsql-sql
Hey guys, I'd like to thank Tom for his suggestion on the joins earlier. I
more/less knew that about the joins but had built everything up and sort of
stuck the sub-selects in there as a band-aid to fix a problem. I re-did all
the queries using nothing but joins and boy, it's a lot faster.

I have one problem though, this is a type of search engine so when I search
I can't display all the results on one screen, it has to be limited. I use
the LIMIT directive in the queries to do so. Before I had been going 2
queries, one to get the total number of results and one to just get 10 of
those results.

So my question is, is there anyway you can get the total number of results
(using count() or something) and still use the limit directive in the same
query? I tried looking at the number of result rows too but 10 (the limit)
is all I come up with.

I would really like to avoid doing 2 full queries here, if anyone has any
suggestions please let me know.

Thanks!!

-Mitch



pgsql-sql by date:

Previous
From: admin
Date:
Subject: making 'like' queries quicker
Next
From: "Ranjan Polavarapu"
Date:
Subject: Oracle Pro*c books