Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id C39699FB9C4 for ; Thu, 24 May 2007 18:47:01 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 96341-08 for ; Thu, 24 May 2007 18:46:55 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from lists.commandprompt.com (host-254.commandprompt.net [207.173.203.254]) by postgresql.org (Postfix) with ESMTP id 7C4A19FB927 for ; Thu, 24 May 2007 18:46:58 -0300 (ADT) Received: from perhan.alvh.no-ip.org (201-221-217-243.bk12-dsl.surnet.cl [201.221.217.243]) (authenticated bits=0) by lists.commandprompt.com (8.13.7/8.13.6) with ESMTP id l4OLkxGK016354; Thu, 24 May 2007 14:46:59 -0700 Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id D8F7C32A14; Thu, 24 May 2007 17:46:54 -0400 (CLT) Date: Thu, 24 May 2007 17:46:54 -0400 From: Alvaro Herrera To: Craig James Cc: pgsql-performance@postgresql.org Subject: Re: LIKE search and performance Message-ID: <20070524214654.GR4320@alvh.no-ip.org> References: <009501c79d4c$445428f0$0b00a8c0@mpsro.dom> <88daf38c0705230905u1a981102k691b47bd36011a80@mail.gmail.com> <4655DE75.4080506@mansionfamily.plus.com> <4655E64B.5050503@hagander.net> <4655FB8A.1040707@mansionfamily.plus.com> <1180040560.31471.262.camel@archimedes> <46560264.2020406@emolecules.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <46560264.2020406@emolecules.com> User-Agent: Mutt/1.5.13 (2006-08-11) X-Virus-Scanned: ClamAV version 0.88.5, clamav-milter version 0.88.5 on projects.commandprompt.com X-Virus-Status: Clean X-Greylist: Sender succeded SMTP AUTH authentication, not delayed by milter-greylist-1.6 (lists.commandprompt.com [192.168.2.159]); Thu, 24 May 2007 14:47:00 -0700 (PDT) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200705/481 X-Sequence-Number: 24871 Craig James wrote: > Mark Lewis wrote: > > >PG could scan the index looking for matches first and only load the > >actual rows if it found a match, but that could only be a possible win > >if there were very few matches, because the difference in cost between a > >full index scan and a sequential scan would need to be greater than the > >cost of randomly fetching all of the matching data rows from the table > >to look up the visibility information. > > Just out of curiosity: Does Postgress store a duplicate of the data in the > index, even for long strings? I thought indexes only had to store the > string up to the point where there was no ambiguity, for example, if I have > "missing", "mississippi" and "misty", the index only needs "missin", > "missis" and "mist" in the actual index. What would happen when you inserted a new tuple with just "miss"? You would need to expand all the other tuples in the index. -- Alvaro Herrera http://www.flickr.com/photos/alvherre/ "Puedes vivir solo una vez, pero si lo haces bien, una vez es suficiente"