On 10.06.2012 14:28, Erik Rijkers wrote:
> Searching for Boyer-Moore in the manual, one only finds the following line (in the 8.4 release
> notes):
>
> "Improve the performance of text_position() and related functions by using Boyer-Moore-
> Horspool searching (David Rowley)"
>
> I have two questions:
>
> 1. Where in postgres is the Boyer-Moore algorithm used? (What happened to text_position() anyway?)
text_position() is in src/backend/utils/adt/varlena.c. It was split into
a few subroutines, which together implement the Boyer-Moore algorithm.
The internal text_position() function backs the SQL-style
POSITION(substring IN string) syntax. In hindsight, the release notes
should've spelled out POSITION(substring IN string), rather than just
assume that people know that text_position() refers to that.
> 2. Shouldn't there be, for 'advocacy' reasons, a mention of this well-known algorithm in the
> manual proper? (I can make a doc-patch if needed)
Doesn't seem necessary to me. I don't see any natural place to put such
a notice in the docs. I think people just rightly assume that the
built-in functions are implemented efficiently, and no need to go into
details.
-- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com