Re: Way to use count() and LIMIT?

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: Way to use count() and LIMIT?
Дата
Msg-id 20011219154822.C15682@svana.org
обсуждение исходный текст
Ответ на Re: Way to use count() and LIMIT?  ("Mitch Vincent" <mitch@doot.org>)
Ответы Re: Way to use count() and LIMIT?  (Darren Ferguson <darren@crystalballinc.com>)
Список pgsql-general
On Tue, Dec 18, 2001 at 09:19:46PM -0700, Mitch Vincent wrote:
> > I gather the reason you don't actually run the whole query is because the
> > resultset would be too large? But you still want the database to work out
> > exactly how many there are.
>
> Not really because it's too large but because there isn't a need.. Imagine
> your favorite search engine, you search and the results are displayed "X
> Matches, displaying matches 1 to 10"... Same thing here -- at least that's
> what my need was... The query executed could get really stout (there were
> over 60 searchable fields across a variety of tables with hundreds of
> thousands of records in some) so executing the count() query, then the other
> certainly added the overhead... A cursor wasn't usable in this situation
> because the user could chose to search once, having only ten results
> displayed of 10,000 and leave the page (thus leaving me with an open
> cursor).....

I'd be tempted to simply limit to 100 or so and if you get over 100, say
"matched over 100 documents". As for the cursor, I don't think google
remembers your results while switching between pages. If you switch back and
forth between pages I'm pretty sure the results change from time to time.

If you think about the number is servers they have, caching query results
would be almost as complicated as the searching itself.
--
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 по дате отправления:

Предыдущее
От: "Mitch Vincent"
Дата:
Сообщение: Re: Way to use count() and LIMIT?
Следующее
От: Darren Ferguson
Дата:
Сообщение: Re: Way to use count() and LIMIT?