Limiting the result set - Mailing list pgsql-novice

From Rob
Subject Limiting the result set
Date
Msg-id MIENLCBGIJDKLHHBLCDGIELKCAAA.rob@jamwarehouse.com
Whole thread Raw
In response to Re: Forgotten the master password of db  (Josh Berkus <josh@agliodbs.com>)
Responses Re: Limiting the result set  (Bruno Wolff III <bruno@wolff.to>)
List pgsql-novice
Hi guys,

I got a bit of an interesting problem I'm hoping someone can help me solve.

I've got a table that's got over 12000 entries in it     and user's can run
searches on it via the
web.  Now, I only ever want to return a maximum of 500 results (for speed
purposes) for any search.

Now, I've got that right by using the LIMIT command, but I also want to be
able to tell the user
how many records matched their search criteria.  So I want to say something
like

"Your search matched 1234 items.  These are the first 500" or some such
thing.

Is there any way, IN ONE QUERY, to do this.  So I want to basically return
the first 500 results
and a count of the total result set in one go.  Is this possible?

If not, what would be the quickest way to do this?  The reason I need one
query is because I use
dynamic SQL, which complicates stuff a bit more

Thanks

Rob
---

He who dies with the most toys ...

                                   ... still dies



pgsql-novice by date:

Previous
From: "Jules Alberts"
Date:
Subject: Re: pg_restore problem
Next
From: Bruno Wolff III
Date:
Subject: Re: Limiting the result set