From: Jerome Alet <alet@librelogiciel.com>
To: pgsql-sql@postgresql.org
Subject: question about index
Date: Thu, 16 Dec 2004 11:41:54 +0100
Message-ID: <20041216104154.GA30578@mail.librelogiciel.com> (raw)
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 WHERE myfield='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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: alet@librelogiciel.com
Subject: Re: question about index
In-Reply-To: <20041216104154.GA30578@mail.librelogiciel.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox