select count... - Mailing list pgsql-hackers

From P. Dwayne Miller
Subject select count...
Date
Msg-id 3B4DF035.B623D72D@espgroup.net
Whole thread Raw
List pgsql-hackers
What's the fastest way to select the number of rows in a table?  If I
use count(*) with no whereclause, it uses a seq_scan and takes 4 secs
(122k rows).  With a where clause, it uses an index and returns in < 1
sec.  Selecting count(requestnumber), which is an indexed column, with
no where clause again takes 4 secs.  This latter version, I thought,
would use the index.  The values of requestnumber are very distributed.

Thanks



pgsql-hackers by date:

Previous
From: Jean-Michel POURE
Date:
Subject: Dependency tracking
Next
From: "Mikheev, Vadim"
Date:
Subject: RE: Re: Strangeness in xid allocation / snapshot setup