pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jean-Luc Lachance <jllachan@nsd.ca>
To: Bruno Wolff III <bruno@wolff.to>
Cc: Dror Matalon <dror@zapatec.com>
Cc: pgsql-performance@postgresql.org <pgsql-performance@postgresql.org>
Subject: Re: count(*) slow on large tables
Date: Thu, 02 Oct 2003 17:29:28 -0400
Message-ID: <3F7C98B8.C892D0E5@nsd.ca> (raw)
References: <20031002191547.GZ87525@rlx11.zapatec.com>
	<20031002193905.GD18417@wolff.to>

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@zapatec.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



view thread (30+ messages)  latest in thread

Message-ID: <3F7C98B8.C892D0E5@nsd.ca>
Permalink:  ../3F7C98B8.C892D0E5@nsd.ca/
Also on:    postgresql.org/message-id/3F7C98B8.C892D0E5@nsd.ca

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: jllachan@nsd.ca, bruno@wolff.to, dror@zapatec.com
  Subject: Re: count(*) slow on large tables
  In-Reply-To: <3F7C98B8.C892D0E5@nsd.ca>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox