Skip site navigation (1) Skip section navigation (2)

Re: count(*) slow on large tables

From: Jean-Luc Lachance <jllachan(at)nsd(dot)ca>
To: Bruno Wolff III <bruno(at)wolff(dot)to>
Cc: Dror Matalon <dror(at)zapatec(dot)com>,"pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: count(*) slow on large tables
Date: 2003-10-02 21:29:28
Message-ID: 3F7C98B8.C892D0E5@nsd.ca (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-performance
That's one of the draw back of MVCC.  
I once suggested that the transaction number and other house keeping
info be included in the index, but was told to forget it...
It would solve once and for all the issue of seq_scan vs index_scan.
It would simplify the aggregate problem.


Bruno Wolff III wrote:
> 
> On Thu, Oct 02, 2003 at 12:15:47 -0700,
>   Dror Matalon <dror(at)zapatec(dot)com> wrote:
> > Hi,
> >
> > I have a somewhat large table, 3 million rows, 1 Gig on disk,  and growing. Doing a
> > count(*) takes around 40 seconds.
> >
> > Looks like the count(*) fetches the table from disk and goes through it.
> > Made me wonder, why the optimizer doesn't just choose the smallest index
> > which in my case is around 60 Megs and goes through it, which it could
> > do in a fraction of the time.
> 
> Because it can't tell from the index if a tuple is visible to the current
> transaction and would still have to hit the table to check this. So that
> performance would be a lot worse instead of better.
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
> 
>                http://www.postgresql.org/docs/faqs/FAQ.html

In response to

Responses

pgsql-performance by date

Next:From: Christopher BrowneDate: 2003-10-02 21:57:30
Subject: Re: count(*) slow on large tables
Previous:From: Vivek KheraDate: 2003-10-02 20:16:58
Subject: Re: inferior SCSI performance

pgsql-hackers by date

Next:From: Christopher BrowneDate: 2003-10-02 21:57:30
Subject: Re: count(*) slow on large tables
Previous:From: DatabaseDate: 2003-10-02 21:10:42
Subject: US-CA DATABASE INTERNALS

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group