question about index

Поиск
Список
Период
Сортировка
От Jerome Alet
Тема question about index
Дата
Msg-id 20041216104154.GA30578@mail.librelogiciel.com
обсуждение исходный текст
Ответы Re: [despammed] question about index
Re: question about index
Список 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 по дате отправления:

Предыдущее
От: Roberto Fichera
Дата:
Сообщение: Query aid
Следующее
От: Andreas Kretschmer
Дата:
Сообщение: Re: [despammed] question about index