select count...

From: "P(dot) Dwayne Miller" <dmiller(at)espgroup(dot)net>
To: PostgreSQL Hackers Newsgroup <pgsql-hackers(at)postgresql(dot)org>
Subject: select count...
Date: 2001-07-12 18:45:09
Message-ID: 3B4DF035.B623D72D@espgroup.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Mikheev, Vadim 2001-07-12 18:48:27 RE: Re: Strangeness in xid allocation / snapshot setup
Previous Message Jan Wieck 2001-07-12 18:39:21 Re: Rule recompilation