title: How to find similar messages in a larggest database
body: <p>I have a database with 2.000.000 messages. When an user receipt a message I need find relevant messages in my database based in occurrence of words.</p>
  
  <p>I had tried run a batch process to summarize my database:
  1 - Store all words(except an, a, the, of, for...) of all messages.
  2 - Create association between all messages and the words contained therein (I also store the frequence of this word appears in the message.)</p>
  
  <p>Then, when I receipt a message:
  1 - I parse words (it looks like with the first step of my batch process.)
  2 - Perform query in database to fetching messages sorted by numbers of coincident words.</p>
  
  <p>However, the process of updating my words base and the query to fetching similar messages are very heavy and slow. The word base update lasts ~1.2111 seconds for a message of 3000 bytes. The query similar messages lasts ~9.8 seconds for a message with same size.</p>
  
  <p>The database tuning already been done and the code works fine.</p>
  
  <p>I need a better algorithm to do it.</p>
  
  <p>Any ideas?</p>