Received: from candle.pha.pa.us (root@s5-03.ppp.op.net [209.152.195.67]) by hub.org (8.9.3/8.9.3) with ESMTP id NAA63161 for ; Tue, 15 Jun 1999 13:33:00 -0400 (EDT) (envelope-from maillist@candle.pha.pa.us) Received: (from maillist@localhost) by candle.pha.pa.us (8.9.0/8.9.0) id NAA11734; Tue, 15 Jun 1999 13:14:33 -0400 (EDT) From: Bruce Momjian Message-Id: <199906151714.NAA11734@candle.pha.pa.us> Subject: Re: [SQL] optimizer woes ? In-Reply-To: from Howie at "Jun 15, 1999 05:11:22 pm" To: Howie Date: Tue, 15 Jun 1999 13:13:18 -0400 (EDT) CC: pgsql-sql@postgreSQL.org X-Mailer: ELM [version 2.4ME+ PL56 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit > ircbot=> explain select nick,hostname,dttime,logtype from logins where > nick=lower('anick') ORDER BY dttime desc; > NOTICE: QUERY PLAN: > > Sort (cost=19913.31 size=0 width=0) > -> Seq Scan on logins (cost=19913.31 size=42498 width=44) > ---[ CUT ]--- > > but when removing the lower(), it uses the index: > > ---[ CUT ]--- > ircbot=> explain select nick,hostname,dttime,logtype from logins where > nick='anick' ORDER BY dttime desc; > > NOTICE: QUERY PLAN: > > Sort (cost=15.68 size=0 width=0) > -> Index Scan using logins_nick_idx on logins (cost=15.68 size=214 > width=44) > ---[ CUT ]--- > > shouldn't the optimizer convert lower('anick') to lowercase first, then > use that value in searching the logins_nick_idx index ? > > btw, this is using postgres 6.4.2 (system is a debian box, p2-350 with > 256m, all uw scsi ) > We have on our TODO list: * Use index with constants on functions Seems we have not implemented it yet. It may be done in 6.5, but I don't think so. -- Bruce Momjian | http://www.op.net/~candle maillist@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026