count() question

From: "Mitch Vincent" <mitch(at)venux(dot)net>
To: <pgsql-sql(at)postgreSQL(dot)org>
Subject: count() question
Date: 1999-12-18 03:56:13
Message-ID: 021101bf490b$d43b7ec0$0300000a@doot.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Ranjan Polavarapu 1999-12-18 12:28:07 Oracle Pro*c books
Previous Message Tom Lane 1999-12-18 01:10:37 Re: [SQL] avg() on numeric ?