constant time count(*) ? - Mailing list pgsql-general

From Mark Harrison
Subject constant time count(*) ?
Date
Msg-id 3F8D8B2A.60800@pixar.com
Whole thread Raw
Responses Re: constant time count(*) ?
Re: constant time count(*) ?
Re: constant time count(*) ?
List pgsql-general
We're looking into moving some data from mysql to postgresql, and
notice that count(*) does not seem to be a constant-time function
as it seems to be in mysql.

planb=# explain select count(*) from assets;
                            QUERY PLAN
----------------------------------------------------------------
  Aggregate  (cost=22.50..22.50 rows=1 width=0)
    ->  Seq Scan on assets  (cost=0.00..20.00 rows=1000 width=0)
(2 rows)

Is there a way to optimize count(*) such that it does not have
to do a sequential scan?  We use this on some big tables and it
is slowing down processing quite a lot.

Thanks!
Mark

--
Mark Harrison
Pixar Animation Studios


pgsql-general by date:

Previous
From: "Rick Gigger"
Date:
Subject: Re: Porting Code to Postgresql
Next
From: "scott.marlowe"
Date:
Subject: Re: VACUUM degrades performance significantly. Database