Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 5C85365014C for ; Fri, 5 Sep 2008 14:02:47 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 84179-08 for ; Fri, 5 Sep 2008 14:02:44 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.169]) by postgresql.org (Postfix) with ESMTP id 1E499650146 for ; Fri, 5 Sep 2008 14:02:43 -0300 (ADT) Received: by ug-out-1314.google.com with SMTP id 29so109946ugo.7 for ; Fri, 05 Sep 2008 10:02:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:mime-version:content-type:content-transfer-encoding :x-priority:x-msmail-priority:x-mailer:in-reply-to:x-mimeole :thread-index:importance; bh=yPuPlzlzZZxQV5ag+bofoOb7yvcXrGeDlTMrJIoHUM4=; b=rcgoYcWIUg5bUcGbnM6odyp+QXkzHDfidnLJnO5ypwunFSpn+vReC09YvSRLeclffR quWx72LK25dawMywIPjNP3BVCPmQMY35C4C5yuoe3yCeW/3h/po0PIqEkFiscq8WHsih CPnCzvsTrYCvCorcuoQop2tAA5RzcSGUTb+sc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding:x-priority:x-msmail-priority:x-mailer :in-reply-to:x-mimeole:thread-index:importance; b=QOIqpUekrUzPpTBYAEPApXKi4Xc4Ww4teqUjGVV22a0Bv7SwdmMOku9PSYmGwLpZAE YVv1Avhaa4SU3xmehvzetCAGwolNWZguX1XZyUyHiobqYYpZUxipNoPSDmB0k3+CAKfi mk3R58JmnMNbYCJ7b43loSeHwJE2LIIqYODMg= Received: by 10.66.248.5 with SMTP id v5mr805428ugh.76.1220634162355; Fri, 05 Sep 2008 10:02:42 -0700 (PDT) Received: from amd64 ( [83.104.138.235]) by mx.google.com with ESMTPS id u1sm939174uge.29.2008.09.05.10.02.41 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 05 Sep 2008 10:02:41 -0700 (PDT) From: "David Rowley" To: "'Heikki Linnakangas'" , "Tom Lane" Cc: "'Peter Eisentraut'" , Subject: Re: [HACKERS] TODO item: Implement Boyer-Moore searching (First time hacker) Date: Fri, 5 Sep 2008 18:02:54 +0100 Message-ID: <2F2A1443F6064162BECA6BB37625222E@amd64> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.6838 In-Reply-To: <48C061B3.1090709@enterprisedb.com> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 Thread-Index: AckO3fNYIqcphxeAQgOqBWN3LNRf/gAmPtcg Importance: Normal X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200809/56 X-Sequence-Number: 7071 Heikki Linnakangas wrote: > After reading the wikipedia article on Boyer-Moore search algorithm, = it=20 > looks to me like this patch actually implements the simpler=20 > Boyer-Moore-Horspool algorithm that only uses one lookup table. That's = > probably fine, as it ought to be faster on small needles and haystacks = > because it requires less effort to build the lookup tables, even = though=20 > the worst-case performance is worse. It should still be faster than = what=20 > we have now. Yes, correct, I really didn't want to slow down smaller searches. This method seemed to fit the bill better. What I didn't realise is that this method also had a name. Tom Lane wrote: > Hmm. B-M-H has worst case search speed O(M*N) (where M =3D length of > pattern, N =3D length of search string); whereas full B-M is O(N). = Maybe we > should build the second table when M is large?=20 I'll look into this. If it pays off for longer searches I'll submit a = patch. I won't have the time until after the 15th, so perhaps that's in = November's commit fest? > The skip table really should be constructed only once in=20 > text_position_start and stored in TextPositionState. That would make a = > big difference to the performance of those functions that call=20 > text_position_next repeatedly: replace_text, split_text and = text_to_array. Of course you are right. That will help for replace and the like. I'll update the patch tonight. Thanks both for the feedback. David.