Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
8450f0a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am using MariaDB 10.0.25 and Sphinxsearch 2.2.9 for fulltext search and reverting this change did not cause any performance problems so far. The attachments table has 6 GB and without fulltext search, it took minutes to do a fulltext search. So it seems that MariaDB is able to plan this query efficiently?
8450f0a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, sorry - I just found out that reverting this change causes MariaDB to only search within the subject... :-(
But anyway, I think it should be configurable where the simple search should search by default.