Indices for select count(*)? - Mailing list pgsql-general

From Alexander Scholz
Subject Indices for select count(*)?
Date
Msg-id dobcn0$24ur$1@news.hub.org
Whole thread Raw
In response to Re: Newbie Question: FAQ for database optimization?  ("A. Kretschmer" <andreas.kretschmer@schollglas.com>)
Responses Re: Indices for select count(*)?
Re: Indices for select count(*)?
Re: Indices for select count(*)?
List pgsql-general
Hi, thank you for your answer.

Regarding the performance flow when trying to find out how many records
are currently being stored in the table, I don't see how an index should
help... Nevertheless we've created an unique index on "ID" but SELECT
count("ID") from "XYZ" still takes 35 seconds*. (ID is the primary key
basing on a sequence, select count(*) isn't faster.)

So - what kind of indexing would speed this up then?

Thanx in advance!

Alexander.

*) MSSQL 2005 on the same server takes 4 seconds for this query for the
analogue table, and there hasn't any special tuning been applied, too.

pgsql-general by date:

Previous
From: S McLurkin
Date:
Subject: contrib extenstions
Next
From: Klein Balázs
Date:
Subject: view or index to optimize performance