Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id ED03B64FCD3 for ; Sun, 7 Sep 2008 08:04:19 -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 32846-02 for ; Sun, 7 Sep 2008 08:04:17 -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.168]) by postgresql.org (Postfix) with ESMTP id 0111064FCC2 for ; Sun, 7 Sep 2008 08:04:16 -0300 (ADT) Received: by ug-out-1314.google.com with SMTP id 29so274609ugo.7 for ; Sun, 07 Sep 2008 04:04:15 -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=fnkJ8PRCDasNDku7lt1QBMmUyisxKwxEMwNsnRN9iXo=; b=Ja6NPF0tpv3U+g5f51tmBy11evUbmzxnJvcGcoKmlgwxb7mcR+JHuxqATmtGMUrKXu C4+H+U1hDMbnA0Ro+bw3xGoYQhNrpQ5Ie0MIBN+XOTdaolb7L2+taHCMbwTm6Bmdhj9H IK088JG8p3FdKY7yWvT28yTHQpy2pars/I3fc= 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=rU1csrIJpP7Cc6G8a91d60sDhPUS3f5rgBuCXjrgTbiYV44gJTklhSBFmTG7GQaa7a TtB8l3dEnHYJKtKv1zKJXNHMnKMXTSC/M9EcWPPamM2nHlqfdNoh6KdPR8n4ia5l3hNi 3LCjeH8PLNG352ih2r+L94IZ6XrFdv1KMKAQ0= Received: by 10.67.40.15 with SMTP id s15mr2699070ugj.67.1220785454807; Sun, 07 Sep 2008 04:04:14 -0700 (PDT) Received: from amd64 ( [83.104.138.235]) by mx.google.com with ESMTPS id e23sm5185560ugd.22.2008.09.07.04.04.12 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 07 Sep 2008 04:04:13 -0700 (PDT) From: "David Rowley" To: "'Tom Lane'" , "'Heikki Linnakangas'" , "'Peter Eisentraut'" Cc: Subject: Re: [PATCHES] TODO item: Implement Boyer-Moore searching (First time hacker) Date: Sun, 7 Sep 2008 12:04:35 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.6838 In-Reply-To: <6183.1220761607@sss.pgh.pa.us> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 Thread-Index: AckQofJwzMQA26Q5ThOEBdVCZtdd0wANZp0g 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/432 X-Sequence-Number: 123561 Tom Lane Wrote: > "David Rowley" writes: > > I've made the discussed changes. Also updated the benchmark results. > > http://www.unixbeast.com/~fat/8.3_test_v1.3.xls > Applied with revisions; mostly cosmetic except for one point. I > realized after studying the code a bit more that B-M cannot possibly win > for a single-character pattern (needle), since the skip distance must > always be 1 in that case. The fact that it seemed to keep up at that > length has to be because the original coding included a strncmp call > inside the innermost loop, which likely prevents the compiler from > optimizing that loop really tightly. But the strncmp wasn't doing > anything anyway for the case of pattern length = 1. So what I committed > special-cases pattern length 1 to be a naive search with a *very* tight > inner loop. I think it's worth troubling over this case because a > common usage is split_to_array and suchlike with single-character > delimiters. I had thought about this, but failed to think about string_to_array. Probably worth the extra code for that. Well simple enough patch. I've learned quite a bit about the postgresql source even just for working in varlena.c. I've got a very long way to go though. Thanks for all the reviews and suggestions. David.