Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9E114475831 for ; Sat, 10 Aug 2002 17:15:26 -0400 (EDT) Received: from mail-relay.trade-india.com (mail-relay.trade-india.com [203.196.129.235]) by postgresql.org (Postfix) with SMTP id 439E8475821 for ; Sat, 10 Aug 2002 17:15:23 -0400 (EDT) Received: (qmail 17930 invoked from network); 10 Aug 2002 21:03:21 -0000 Received: from unknown (HELO www.trade-india.com) (130.94.20.27) by infocom-236-129-del.trade-india.com with SMTP; 10 Aug 2002 21:03:21 -0000 Received: (qmail 1957 invoked by uid 99); 10 Aug 2002 21:14:17 -0000 Received: from 203.145.129.36 (proxying for 203.145.131.140) (SquirrelMail authenticated user mallah) by mail.trade-india.com with HTTP; Sun, 11 Aug 2002 02:44:17 +0530 (IST) Message-ID: <49280.203.145.129.36.1029014057.squirrel@mail.trade-india.com> Date: Sun, 11 Aug 2002 02:44:17 +0530 (IST) Subject: Re: getting ILIKE or ~* to use indexes.... From: To: In-Reply-To: References: <200208101143.54041.mallah@trade-india.com> X-Priority: 3 Importance: Normal X-MSMail-Priority: Normal Cc: , X-Mailer: SquirrelMail (version 1.2.6) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/179 X-Sequence-Number: 9025 Thanks Josh I normally use tsearch for full text search i will probably use that or may be this what u suggested. regds mallah. > Rajesh, > >> I want my query to use indexes for company name searches but its not happening unless >> is use '=' which does not server the purpose. >> >> eg >> >> tradein_clients=# explain SELECT co_name FROM unified_data where co_name ilike '%rajesh%' ; > > Well, for an *anchored* case-insensitive search, you can create an index on lower(field_name) > to use an index. > > CREATE INDEX idx_uni_co_name ON unifed_data(lower(co_name)); > SELECT co_name FROM unified_data where > lower(co_name) LIKE (lower('rajesh') || '%') ; > > And that will use the index. > > However, what you are doing is an *unanchored* text search, meaning that you are searching for > 'rajesh' anywhere in the field. No standard index can help you with that. > > Instead, you should look into Full Text Search tools. There's a simple one in /contrib in the > Postgresql source, and an more robust one > available from the OpenFTS project. > > -Josh Berkus ----------------------------------------- Get your free web based email at trade-india.com. "India's Leading B2B eMarketplace.!" http://www.trade-india.com/