From: Bruno Wolff III <bruno@wolff.to>
To: Kris Kiger <kris@musicrebellion.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: Indexing a boolean
Date: Thu, 21 Aug 2003 16:13:07 -0500
Message-ID: <20030821211307.GA7194@wolff.to> (raw)
In-Reply-To: <3F452FEB.60902@musicrebellion.com>
References: <4.3.2.7.2.20030528141514.03235970@mira-sjc5-5.cisco.com>
<163726734.20030531182048@gorodok.net>
<3F452FEB.60902@musicrebellion.com>
On Thu, Aug 21, 2003 at 15:47:39 -0500,
Kris Kiger <kris@musicrebellion.com> 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.
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: bruno@wolff.to, kris@musicrebellion.com
Subject: Re: Indexing a boolean
In-Reply-To: <20030821211307.GA7194@wolff.to>
References: <4.3.2.7.2.20030528141514.03235970@mira-sjc5-5.cisco.com> <163726734.20030531182048@gorodok.net> <3F452FEB.60902@musicrebellion.com> <20030821211307.GA7194@wolff.to>
* 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