Improve summary search speed on large installs.

Review Request #6494 — Created Oct. 23, 2014 and submitted — Latest diff uploaded

Information

Review Board
release-2.0.x
2d2f812...

Reviewers

Search for summaries in the quick search is very slow, for a couple of
reasons. We didn't have an index on the summary, but even if we did,
we were looking for text in the middle of the summary field, which
indexes can't help with.

This could cause real problems on large installs, slowing down the
database making it nearly impossible to find what you're looking for.
Continuing to type would trigger further expensive queries, eventually
resulting in other queries stalling on the server.

To fix this, we now have an index, and we now search only the beginnings
of summaries. We also only start searching if we have 4 or more
characters. It limitation on where we search sucks, but it's better than
nothing.

Theoretically, we could use the search index, but more work must be done
to make that happen.

We could also, theoretically, use the full-text search feature for
MySQL, but not all versions support that for InnoDB. Work would need to
be done to introspect whether we can use full-text search, and it would
require hand-applying some SQL to the database. It also wouldn't buy us
anything for other types of databases.

This may limit the usefulness of quick search for summaries until we
come up with something clever, but at least it won't break servers.

Tested search locally. It didn't check summaries until I entered my 5th
character. Then it did prefix matching instead of searching within text.

Tested the query with MySQL using EXPLAIN, and saw that it was using the
index and substantially limited the number of rows it had to search.