[Rt-commit] rt branch, 4.2/simple-search-content-only, created. rt-4.2.9-138-g8450f0a

Alex Vandiver alexmv at bestpractical.com
Wed Feb 4 16:28:20 EST 2015


The branch, 4.2/simple-search-content-only has been created
        at  8450f0a9f233d6a761ac22dbdf14926abc54d7fa (commit)

- Log -----------------------------------------------------------------
commit 8450f0a9f233d6a761ac22dbdf14926abc54d7fa
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Feb 4 16:17:33 2015 -0500

    Only search Content, not Content and Subject, for better indexing
    
    A TicketSQL query of « Subject LIKE 'word' OR Content LIKE 'word' »
    generates the following SQL (simplified):
    
        SELECT DISTINCT main.*
          FROM Tickets main
               JOIN Transactions Transactions_1
                 ON ( Transactions_1.ObjectType = 'RT::Ticket' )
                AND ( Transactions_1.ObjectId = main.id )
          LEFT JOIN Attachments Attachments_2
                 ON ( Attachments_2.TransactionId = Transactions_1.id )
         WHERE main.Subject LIKE '%word%'
            OR Attachments_2.Content MATCHES 'word'
    
    This leaves both MySQL and Postgres unable to use their full-text-search
    indexes on the Content search, as their query planner cannot separate
    this unto a union of two queries which are both well-indexed.  Instead,
    both databases elect to perform sequential scans of all three involved
    tables.  While the full-text index does speed this process, the
    sequential scans nonethless cause the query to take noticable time.
    
    For the common case of simple search with FTS enabled, default to
    searching the Content rather than suffer the performance penalties of
    searching both.  In nearly all cases, the words of the subject are
    contained within the words of the content; later work will ensure that
    the full-text-search index contains the information from the subject,
    allowing a performant but fully inclusive search.

diff --git a/lib/RT/Search/Simple.pm b/lib/RT/Search/Simple.pm
index 039f7c7..4cb2482 100644
--- a/lib/RT/Search/Simple.pm
+++ b/lib/RT/Search/Simple.pm
@@ -245,7 +245,7 @@ sub GuessType {
 sub HandleDefault   {
     my $fts = RT->Config->Get('FullTextSearch');
     if ($fts->{Enable} and $fts->{Indexed}) {
-        return default => "(Subject LIKE '$_[1]' OR Content LIKE '$_[1]')";
+        return default => "Content LIKE '$_[1]'";
     } else {
         return default => "Subject LIKE '$_[1]'";
     }

-----------------------------------------------------------------------


More information about the rt-commit mailing list