Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id EEDE164FCC1 for ; Sun, 7 Sep 2008 01:27:43 -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 45212-09 for ; Sun, 7 Sep 2008 01:27:23 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 2540964FCBA for ; Sun, 7 Sep 2008 01:27:23 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id m874Qlcr006184; Sun, 7 Sep 2008 00:26:48 -0400 (EDT) To: "David Rowley" cc: "'Heikki Linnakangas'" , "'Peter Eisentraut'" , pgsql-hackers@postgresql.org Subject: Re: [PATCHES] TODO item: Implement Boyer-Moore searching (First time hacker) In-reply-to: <2B14F8402C8E4A3C9E240E3DAF31BA25@amd64> References: <2B14F8402C8E4A3C9E240E3DAF31BA25@amd64> Comments: In-reply-to "David Rowley" message dated "Sun, 07 Sep 2008 03:03:57 +0100" Date: Sun, 07 Sep 2008 00:26:47 -0400 Message-ID: <6183.1220761607@sss.pgh.pa.us> From: Tom Lane 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/429 X-Sequence-Number: 123558 "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. regards, tom lane