I have a database app running on MySQL. Most of it is running very nicely, but my big problem is that I need to execute fast fulltext searches against one of the tables, and the built-in MySQL fulltext capability just isn't fast enough for common words.

The table in question has about 3M rows, and the relevant field averages maybe 20-30 words. It's perfectly fine when searching for not-extremely-common words, but I need to be able to search on anything (I've changed the minimum-word-length to 2 characters, and eliminated the stopword list). Doing searches for phrases like "the thing is" or "he said" can take many seconds or even minutes, and this is not an artificial need, but a common search that the app must be able to handle.

Most of the things I've looked at for fulltext searches are concerned with things like stemming, or fuzzy matching, or result ranking. I'm interested in none of those things, I only want an exact result quickly. I tried for example DBIx::FullTextSearch, but, while superficially appealing, this (1) took 250 times longer to build the indexes than in the MySQL built-in, and (2) didn't really run any faster (it was hard to benchmark, but if there was a difference it was slight).

I also looked at the Vector Space search engine, and the Perlmonks discussion of it, and while this looks really cool, it didn't seem as if that was especially fast either, and besides I don't have the math chops to really get this working.

I haven't tried the recent perl.com article on Adding Search Functionality to Perl Applications, but it seems that that's geared more towards stemming and ranking than in raw speed.

Does anyone have a suggestion? I know most people aren't trying to match "in it", but some people are, and Google can do it quickly, and I hope there's a way of accomplishing this.


In reply to Fulltext DB search: The Need for Speed by jest

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.