X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 374DAD1B567 for ; Mon, 29 Sep 2003 17:05:27 +0000 (GMT) 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 23200-05 for ; Mon, 29 Sep 2003 14:04:59 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 0055ED1B55A for ; Mon, 29 Sep 2003 14:04:58 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3694828; Mon, 29 Sep 2003 10:03:29 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Alex Kretschmer Subject: Re: postgres index on ILIKE Date: Mon, 29 Sep 2003 10:02:14 -0700 User-Agent: KMail/1.4.3 References: <3F7824A8.2010704@gmx.de> In-Reply-To: <3F7824A8.2010704@gmx.de> Cc: pgsql-sql@postgresql.org MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200309291002.14823.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/395 X-Sequence-Number: 15373 Alex, > I read your article about indexing in postgres which unfortunately ends > after the 2nd part. So I decided to ask you by email. Yeah, yeah, I know. The completed version will probably become part of a published book. We'll see. > Is it somehow possible to create an index for the ILIKE comparision? > I set up a database which contains the paths to all files in my network > neighborghood. Short of creating your own datatype, you can't index for ILIKE. Instead, you create an index on the LOWER() of the column ... CREATE INDEX idx_table_lower_text ON table(lower(text_field)); Then, you make sure when querying to query the lower function: SELECT * FROM table WHERE lower(text_field) LIKE 'xxxyy%'; This will use the index wherever it improves execution. I suggest that you join the PGSQL-SQL mailing list for future questions of this type. -- Josh Berkus Aglio Database Solutions San Francisco