Re: Way to use count() and LIMIT?

From: Joe Koenig <joe(at)jwebmedia(dot)com>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Way to use count() and LIMIT?
Date: 2001-12-19 14:44:23
Message-ID: 3C20A7C7.8963C04B@jwebmedia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

That's so rediculously simple it hurts...I'm an idiot...Thank you VERY much.

Joe

Martijn van Oosterhout wrote:
>
> 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(at)svana(dot)org>
> http://svana.org/kleptog/
> > Terrorists can only take my life. Only my government can take my freedom.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Troy.Campano 2001-12-19 15:06:06 Outputting select into file.
Previous Message Stephan Szabo 2001-12-19 14:25:17 Re: Query hangs when getting too complex...