Skip site navigation (1) Skip section navigation (2)

Re: select count(*) performance

From: "slawekj" <slawekj(at)nospam(dot)net>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: select count(*) performance
Date: 2007-08-09 14:44:41
Message-ID: f9f980$v21$ (view raw, whole thread or download thread mbox)
Lists: pgsql-performance
> I'm new in PostgreSQL Business, therefore please forgive me a "newbie"
> Question. I have a table with ca. 1.250.000 Records. When I execute
> a "select count (*) from table" (with pgAdmin III)  it takes about 40
> secs.
> I think that takes much to long. Can you please give me hints, where
> I can search for Improvements?
> TIA, Det

maybe try change shared_buffers and test it,

or you can create trigger on this table after insert and delete
if insert then increse value in another table "counts"
if delete then decrese
and now you dont must execute select count(*) ...
but execute
select my_count from counts where tablename='your_table'


In response to

pgsql-performance by date

Next:From: Decibel!Date: 2007-08-09 15:32:15
Subject: Re: Update table performance
Previous:From: Vivek KheraDate: 2007-08-09 14:40:30
Subject: Re: mid 2007 "best bang for the buck" hardware opinions

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group