Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id BFE4E9FC12E for ; Fri, 25 May 2007 14:58:38 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 97579-01 for ; Fri, 25 May 2007 14:58:36 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from oxford.xeocode.com (unknown [87.127.95.194]) by postgresql.org (Postfix) with ESMTP id 6AF659FB7DF for ; Fri, 25 May 2007 14:58:35 -0300 (ADT) Received: from localhost ([127.0.0.1] helo=oxford.xeocode.com) by oxford.xeocode.com with esmtp (Exim 4.67) (envelope-from ) id 1Hre3J-0002ZQ-GW; Fri, 25 May 2007 18:58:13 +0100 From: Gregory Stark To: "Richard Huxton" Cc: , "Mark Lewis" , "James Mansion" , "Magnus Hagander" , "Alexander Staubo" , "Andy" , Subject: Re: LIKE search and performance In-Reply-To: <46571CEC.7070202@archonet.com> (Richard Huxton's message of "Fri, 25 May 2007 18:29:16 +0100") Organization: EnterpriseDB 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> <20070524215450.GA3858@mark.mielke.cc> <46569AA5.10205@archonet.com> <20070525141630.GA12162@mark.mielke.cc> <4657023A.20209@archonet.com> <20070525165633.GA13579@mark.mielke.cc> <46571CEC.7070202@archonet.com> X-Draft-From: ("nnimap+mail01.enterprisedb.com:INBOX.performance" 648) Date: Fri, 25 May 2007 18:58:13 +0100 Message-ID: <87y7jckcp6.fsf@oxford.xeocode.com> User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200705/529 X-Sequence-Number: 24919 "Richard Huxton" writes: > Now you and I can look at a substring and probably make a good guess how common > it is (assuming we know the targets are British surnames or Japanese towns). PG > needs one number - or rather, it picks one number for each length of > search-string (afaik). I don't think that's true. Postgres calculates the lower and upper bound implied by the search pattern and then uses the histogram to estimate how selective that range is. It's sometimes surprisingly good but obviously it's not perfect. -- Gregory Stark EnterpriseDB http://www.enterprisedb.com