From: Tomasz Myrta <jasiek@klaster.net>
To: 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 21:36:42 +0200
Message-ID: <3F7C7E4A.9080803@klaster.net> (raw)
In-Reply-To: <20031002191547.GZ87525@rlx11.zapatec.com>
References: <20031002191547.GZ87525@rlx11.zapatec.com>
> 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.
>
> Dror
Just like other aggregate functions, count(*) won't use indexes when
counting whole table.
Regards,
Tomasz Myrta
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: jasiek@klaster.net, dror@zapatec.com
Subject: Re: count(*) slow on large tables
In-Reply-To: <3F7C7E4A.9080803@klaster.net>
* 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