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-13 07:46:25
Message-ID: op.vkh7vno8eorkce@apollo13
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-performance


> I guess I have to comment here again and point out that while I am
> having this
> issue with text searches, I avoid using count(*) in such cases, I just
> use
> next and previous links.

Unfortunately sometimes you got to do an ORDER BY on search results, and
then all the rows got to be read...

> Where the real problem (for me) is that when someone
> searches a date or time range. My application keeps track of huge

Have you tried CLUSTER ?

Also, it is sad to say, but if you need an engine able to use index-only
scans which would fit this type of query, replicate the table to MyISAM.
Unfortunately, the MySQL optimizer is really not so smart about complex
reporting queries (no hash joins, no hash aggregates) so if you don't have
a multicolumn index covering that you can use for index-only scan in your
query, you'll get either a really huge sort or a really nasty nested loop
index scan...

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Markus Wanner 2010-10-13 08:05:14 Re: Issues with Quorum Commit
Previous Message Dimitri Fontaine 2010-10-13 07:41:45 Re: SQL command to edit postgresql.conf, with comments

Browse pgsql-performance by date

  From Date Subject
Next Message Craig Ringer 2010-10-13 08:11:48 Re: SQL functions vs. PL/PgSQL functions
Previous Message Reuven M. Lerner 2010-10-13 07:30:45 SQL functions vs. PL/PgSQL functions