Re: Yet Another COUNT(*)...WHERE...question

From: Rainer Bauer <usenet(at)munnin(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Yet Another COUNT(*)...WHERE...question
Date: 2007-08-16 15:53:56
Message-ID: r6s8c39e76mic12ai56akdauj1rv0ahuti@4ax.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Bill Moran wrote:

>> Consider this query with multiple WHERE conditions:
>> <http://search.ebay.com/ne-ol-an_W0QQfasiZ1QQfbdZ1QQfcdZ1QQfcidZ77QQfclZ3QQfmcZ1QQfrppZ50QQfsooZ1QQfsopZ1QQftidZ1QQpriceZ1QQsabdhiZ100QQsacurZ999QQsalicZQ2d15QQsaprchiZ50000QQsatitleZQ28neQ2aQ2colQ2aQ2canQ2aQ29QQsojsZ0>
>>
>> My point is that whatever search criterias are involved and how many items are found eBay always returns the *accurate* number of items found.
>
>While I don't _want_ to argue with you ... I can't seem to help myself.
>
>How do you _know_ that's the exact number of items? There are 50 items on
>that page, the paginator at the bottom shows 97,686 pages, but there's no
>way (that I can find) to go to the _last_ page to ensure that said numbers
>are correct. It could simply be estimating the number of items and
>calculating the # of pages based on that. With 4mil items, a few 1000 off
>isn't anything anyone would notice.

No, those numbers are correct. You can go to the last page using the input box
at the end of the listing "Go to page". However, with a 4 million result set,
the count will have changed while the last page is retrieved (new items have
been listed and otheres have ended in the mean time). You will have to check
this out with a search yielding fewer results (couple of hundred thousands)
and load the first and last page simultaneously.

>> * I realize that pagination for multi-million tuple results does not make sense.
>
>Then what is the point to this thread? Are we just shooting the breeze at
>this point?

I just wanted to show an example where accurate counts are reported for large
search results.

Rainer

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Rainer Bauer 2007-08-16 15:54:01 Re: Yet Another COUNT(*)...WHERE...question
Previous Message Rodrigo De León 2007-08-16 15:51:33 Re: Yet Another COUNT(*)...WHERE...question