Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id BD5C79FB433 for ; Tue, 6 Mar 2007 18:28:12 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 50253-03 for ; Tue, 6 Mar 2007 18:28:09 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from main2.mycybernet.net (main2.mycybernet.net [209.222.63.140]) by postgresql.org (Postfix) with ESMTP id 3E1089FB32A for ; Tue, 6 Mar 2007 18:28:08 -0400 (AST) Received: from 227-54-222-209.mycybernet.net ([209.222.54.227] helo=phlogiston.dydns.org) by main2.mycybernet.net with esmtp (Exim 4.62) (envelope-from ) id 1HOiNn-00084J-3B for pgsql-sql@postgresql.org; Tue, 06 Mar 2007 17:43:47 -0500 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id 78B26404E; Tue, 6 Mar 2007 17:28:02 -0500 (EST) Date: Tue, 6 Mar 2007 17:28:02 -0500 From: Andrew Sullivan To: pgsql-sql@postgresql.org Subject: Re: best index for ~ ordering? Message-ID: <20070306222802.GA16606@phlogiston.dyndns.org> References: <45EDDE5F.2030303@fmed.uba.ar> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <45EDDE5F.2030303@fmed.uba.ar> User-Agent: Mutt/1.5.9i X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200703/63 X-Sequence-Number: 27701 On Tue, Mar 06, 2007 at 06:34:23PM -0300, Gerardo Herzig wrote: > Hi all, i have a large table with one varchar field, and im triyng to > get information about what index should i use in order to using that > index (if this is possible) for ~ searching, and/or using LIKE searching. What sort of match are you doing? If you're doing left-anchored searches (LIKE 'blah%') then your standard btree is good. If you're doing unanchored searches (LIKE '%blah%' or similar) you're best doing tsearch. If it's right-anchored, you can do an index on the reverse of the string. A -- Andrew Sullivan | ajs@crankycanuck.ca Unfortunately reformatting the Internet is a little more painful than reformatting your hard drive when it gets out of whack. --Scott Morris