X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 0B3E3D1B8BF for ; Thu, 21 Aug 2003 18:07:48 -0300 (ADT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 53824-05 for ; Thu, 21 Aug 2003 18:07:19 -0300 (ADT) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id 9488AD1BB5E for ; Thu, 21 Aug 2003 18:07:16 -0300 (ADT) Received: (qmail 7214 invoked by uid 500); 21 Aug 2003 21:13:07 -0000 Date: Thu, 21 Aug 2003 16:13:07 -0500 From: Bruno Wolff III To: Kris Kiger Cc: pgsql-admin@postgresql.org Subject: Re: Indexing a boolean Message-ID: <20030821211307.GA7194@wolff.to> Mail-Followup-To: Kris Kiger , pgsql-admin@postgresql.org References: <4.3.2.7.2.20030528141514.03235970@mira-sjc5-5.cisco.com> <163726734.20030531182048@gorodok.net> <3F452FEB.60902@musicrebellion.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3F452FEB.60902@musicrebellion.com> User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/258 X-Sequence-Number: 9979 On Thu, Aug 21, 2003 at 15:47:39 -0500, Kris Kiger wrote: > I would appreciate it if I could get some thoughts on indexing a field > with only two values? For example, I have a table with a few million > rows in it. All items in this table are broken up into two categories > using 'T' or 'F'. It seems logical to me that an index on this field > would create two logical 'buckets', so that one could say, "I want all > 'T' values", or "I want all 'F' values" and merely have to look in the > appropriate bucket, rather than have to perform a sequential scan > through three million items every time a request is made based on 'T' or > 'F'. If I were to create an index on a char(1) field that contains only > values of 'T' or 'F', would the query analyzer override the use of this > index? How does Postgres address this problem and what are all of your > thoughts on this issue? I appreciate the help! You probably don't want to use an index unless one of the two values is much more common than the other. In that case you want to use a partial index on the rare condition.