Re: Slow count(*) again...

From: "Pierre C" <lists(at)peufeu(dot)com>
To: "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>, "Neil Whelchel" <neil(dot)whelchel(at)gmail(dot)com>
Subject: Re: Slow count(*) again...
Date: 2010-10-12 21:35:01
Message-ID: op.vkhfkn1yeorkce@apollo13
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-performance


> suggest that 99% instances of the "select count(*)" idiom are probably
>> bad use of the SQL language.

Well, suppose you paginate results. If the user sees that the search query
returns 500 pages, there are two options :

- you're google, and your sorting algorithms are so good that the answer
the user wants is in the first page
- or the user will refine his search by entering more keywords tu get a
manageable result set

So, in both cases, the count(*) was useless anyway. And the slowest ones
are the most useless, since the user will immediatey discard the result
and refine his query.

If your full text search is slow, try Xapian or Lucene.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kevin Grittner 2010-10-12 21:51:06 Re: SQL command to edit postgresql.conf, with comments
Previous Message Darren Duncan 2010-10-12 21:33:37 Re: SQL command to edit postgresql.conf, with comments

Browse pgsql-performance by date

  From Date Subject
Next Message Neil Whelchel 2010-10-12 22:21:31 Re: Slow count(*) again...
Previous Message Tom Lane 2010-10-12 21:22:14 Re: bulk load performance question