X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5076F3B6D76 for ; Thu, 16 Dec 2004 10:42:03 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 98455-10 for ; Thu, 16 Dec 2004 10:41:54 +0000 (GMT) Received: from nordine.ateur (main.librelogiciel.com [62.212.108.58]) by svr1.postgresql.org (Postfix) with ESMTP id 284963B6DAE for ; Thu, 16 Dec 2004 10:41:55 +0000 (GMT) Received: from jerome by nordine.ateur with local (Exim 3.36 #1 (Debian)) id 1Cet50-00080q-00 for ; Thu, 16 Dec 2004 11:41:54 +0100 Date: Thu, 16 Dec 2004 11:41:54 +0100 To: pgsql-sql@postgresql.org Subject: question about index Message-ID: <20041216104154.GA30578@mail.librelogiciel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.6+20040907i From: Jerome Alet X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200412/101 X-Sequence-Number: 19721 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