From: | Varun Mehta <vmehta(at)apple(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Make COUNT(*) Faster? |
Date: | 2005-07-07 22:48:39 |
Message-ID: | 9EF2931D-1097-470D-8ECB-59D00166C96F@apple.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hello all you PostgreSQL/SQL gurus!
I've started using PostgreSQL pretty recently, and I am quite
disturbed about the performance of a simple SELECT COUNT(*) FROM
table. What should (in my mind) be a nearly instantaneous operation
instead takes nearly 700ms in a table with only 87k rows of data!
If I run an EXPLAIN on this query I can see that it is doing a
sequential scan, which seems quite needless, as surely this
information is cached in some secret location.
It is very possible that I am missing something, so I ask you: is
there a faster way to find out how many rows are in a table? I've
tried doing a COUNT(column) where I have an index on column, but it
still does a sequential scan and it is still very very slow. What
are my options?
I offer you many thanks in advance,
Varun Mehta
From | Date | Subject | |
---|---|---|---|
Next Message | PFC | 2005-07-07 23:54:46 | Re: getting back autonumber just inserted |
Previous Message | Michael Fuhr | 2005-07-07 22:44:52 | Re: getting back autonumber just inserted |