SimpleMessageSearchIndex has O(n^2) performance for searches at the moment. This leads to very bad message check performance for e.g the Android Mailclient on big mailboxes.
The reason for that is that the current code buffers messages in an ArrayList while performing an contains() check before each add(). A TreeSet is more appropriate here reducing runtime to O(n*log).
Furthermore the existing UID range optimization is not effective when other criteria are conjugated with the query.