From: | Sheldon Hearn <sheldonh(at)starjuice(dot)net> |
---|---|
To: | pgsql-general(at)PostgreSQL(dot)org |
Subject: | COUNT(*) very slow on table with primary key |
Date: | 2001-08-14 11:47:20 |
Message-ID: | 99314.997789640@axl.seasidesoftware.co.za |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi folks,
I've been having trouble with a slow query on a table that has a primary
key (which I understand is supported in PostgreSQL by a UNIQUE non-NULL
index). It's a SELECT COUNT(*) without a WHERE clause; really simple
stuff.
I would have thought the number of entries in the primary key index
could simply be inspected and returned.
EXPLAIN reports that a sequential table scan is being performed, which
sounds right, since the actual operation takes about 10 seconds when
there are about half a million rows in the table.
The table's pretty wide (about 2.5KB), but has been subjected to a
VACUUM ANALYZE operation in accordance with the advice given in the FAQ.
Is this just "how it is" or is there more stuff I could look at? I'm
actually trying to speed up a more complex query, but figured it would
be better to report (and get feedback on) the simplest case.
Ciao,
Sheldon.
From | Date | Subject | |
---|---|---|---|
Next Message | Jochem van Dieten | 2001-08-14 13:38:08 | PostgresQL equivalent of NOCOUNT |
Previous Message | Hicnar | 2001-08-14 10:45:56 | A libpq++ question. |