Unix Technical Forum

count(*) index

This is a discussion on count(*) index within the pgsql Novice forums, part of the PostgreSQL category; --> Hi! Yes, i know, mvcc, and can't use indexes. And i know the workaround for max() and min(). Is ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Novice

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-17-2008, 08:19 PM
Tomka Gergely
 
Posts: n/a
Default count(*) index

Hi!

Yes, i know, mvcc, and can't use indexes. And i know the workaround for
max() and min(). Is there some workaround for count()?

select count(*) from table where field=1;

and field has a nice index. And this is slooooow.

--
Tomka Gergely
Tudom, anyu. Sapka, sál, doksi.

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-17-2008, 08:19 PM
Bruno Wolff III
 
Posts: n/a
Default Re: count(*) index

On Fri, Jan 07, 2005 at 19:22:56 +0100,
Tomka Gergely <tomka@zeus.gau.hu> wrote:
> Hi!
>
> Yes, i know, mvcc, and can't use indexes. And i know the workaround for
> max() and min(). Is there some workaround for count()?
>
> select count(*) from table where field=1;
>
> and field has a nice index. And this is slooooow.


If there are few records where field=1 then an index will be used.

You may get better performance maintaining a count table using triggers.
This may not work well of there are lots of concurrent updates.

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 01:35 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com