Re: Way to use count() and LIMIT? - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: Way to use count() and LIMIT?
Date
Msg-id 20011220011606.B16349@svana.org
Whole thread Raw
In response to Re: Way to use count() and LIMIT?  (Joe Koenig <joe@jwebmedia.com>)
List pgsql-general
On Wed, Dec 19, 2001 at 08:13:50AM -0600, Joe Koenig wrote:
> This is exactly right. The table I'm searching has 220,000 records right
> now, and growing. The "Rock" category within "CD's" will return over
> 53,000 results. The count isn't so much for display, as for knowing
> whether or not to put a "next" button on the page. I don't want to
> always have next buttons, but not always have more results. There is
> currently the option to browse through results based on the first letter
> of the result, which I guess I could make as the 3rd step and not run
> the query that currently returns 53,000 results until they narrow it
> down more. I wasn't really expecting this to be possible, but PG does so
> many other things that I didn't think was possible, so I thought I'd ask :)

But that's easy. Simply ask the database for one more record that you're
going to display. If you get that extra record, then display the next
button, otherwise don't. The count is irrelevent.

--
Martijn van Oosterhout <kleptog@svana.org>
http://svana.org/kleptog/
> Terrorists can only take my life. Only my government can take my freedom.

pgsql-general by date:

Previous
From: Joe Koenig
Date:
Subject: Re: Way to use count() and LIMIT?
Next
From: Joe Koenig
Date:
Subject: Re: Way to use count() and LIMIT?