I have a continuous stream of messages which are analyzed. The analysis returns different variables, like author, topic, sentiment, word-count and a set of distinct words. Users in the system are able to define rules, which should trigger an alert, when matched. The rules should be stored in a sql-database. A rule is a conjunction of single criteria from the message analysis, i.e. word-count > 15 && topic = 'StackOverflow'&& sentiment > 2.0 && word-set contains 'great'. Each allowed rule-criteria is provided at the end of the message analysis, after which the rule validation will be triggered and which is implemented in Java.
Every message has to be checked for all the rules defined by all users in the system, which takes up a lot of computation power (there are currently 10+ messages/second and there will be 10.000+ rules to check). Is there a common pattern to speed up the matching process, maybe so that the rules can be checked in parallel, except one-by-one? Is it possible to do this in pure SQL, how would a schema for rules of different types look like?