question about index - Mailing list pgsql-sql

From Jerome Alet
Subject question about index
Date
Msg-id 20041216104154.GA30578@mail.librelogiciel.com
Whole thread Raw
Responses Re: [despammed] question about index
Re: question about index
List pgsql-sql
Hi,

For a future databas, I plan to have got a table with a text field 
which can contain only three different values, say "VALUE1", 
"VALUE2", and "VALUE3" 

this table may have, over the course of one year, several million
rows for a size around 2 Gb or more.

I'd be interested in having :
       SELECT count(*) AS nbvalue1 FROM mytable WHERE myfield='VALUE1';       SELECT count(*) AS nbvalue2 FROM mytable
WHEREmyfield='VALUE2';       SELECT count(*) AS nbvalue3 FROM mytable WHERE myfield='VALUE3';       
 
be as fast as possible.        

considering that almost 70% of the rows will be with 'VALUE1', 20%
will be with 'VALUE2' and 10% will be with 'VALUE3' on the average.

should I create an index to speedup the counts or not ?

any idea of the impact of running these three queries every 5 minutes
on say 10 000 000 rows ?

thanks in advance

Jerome Alet


pgsql-sql by date:

Previous
From: Roberto Fichera
Date:
Subject: Query aid
Next
From: Andreas Kretschmer
Date:
Subject: Re: [despammed] question about index