X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 112DAD1B25F for ; Wed, 19 May 2004 23:01:38 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 15208-07 for ; Wed, 19 May 2004 23:01:21 -0300 (ADT) Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 0EB5ED1B19C for ; Wed, 19 May 2004 23:01:17 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id i4K20xm12757; Wed, 19 May 2004 22:00:59 -0400 (EDT) From: Bruce Momjian Message-Id: <200405200200.i4K20xm12757@candle.pha.pa.us> Subject: Re: index not used for boolean In-Reply-To: <1083681101.24739.21.camel@watto.interprose.net> To: Greg Johnson Date: Wed, 19 May 2004 22:00:59 -0400 (EDT) Cc: Gaetano Mendola , pgsql-admin@postgresql.org X-Mailer: ELM [version 2.4ME+ PL108 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200405/206 X-Sequence-Number: 13522 OK, TODO updated: * Allow col IS TRUE/FALSE use an index like col = TRUE/FALSE --------------------------------------------------------------------------- Greg Johnson wrote: > I just ran into this yesterday also. I was trying > select * from foo where expired IS TRUE > and the index was not used, but when I switched it to expired = true it > worked... Very frustrating bug.. wasted about 3 hours planning and > analyzing the simple query. > > On Tue, 2004-05-04 at 00:04, Gaetano Mendola wrote: > > > Hi all, > > is it normal that in a select like: > > > > select * from foo where expired; > > > > the index on expired is not used? > > > > If I rewrite that query: > > > > select * from foo where expired = true; > > > > then the index is used! > > > > I'm using postrgres 7.4.2 > > > > > > Regards > > Gaetano Mendola > > > > ---------------------------(end of broadcast)--------------------------- > > TIP 6: Have you searched our list archives? > > > > http://archives.postgresql.org -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073