Indices for select count(*)?

From: Alexander Scholz <alexander(dot)scholz1(at)freenet(dot)de>
To: pgsql-general(at)postgresql(dot)org
Subject: Indices for select count(*)?
Date: 2005-12-21 11:01:57
Message-ID: dobcn0$24ur$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alban Medici (NetCentrex) 2005-12-21 11:10:33 Re: [PERFORM] need help
Previous Message Richard Huxton 2005-12-21 09:46:59 Re: Questions about server.