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

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Reply via email to