Searching Efficiency - Which is faster comparing 10 ints or one 30 bytes string? <p>I'm going to make a sentiment analysis project, with a website frontend to use it. It's designed to analise twitter posts. The analised documents will be put in a database. </p> <p>I'm going to group retrieved posts by the search term in the database. </p> <p>In order to make the database operations faster, I wouldn't like to compare search terms in strings, the idea is to transform the search terms into numbers and use them to find entries in the database.</p> <p>The function I thought of to transform the strings in numbers would be something as follows:</p> <ul> <li>a = 067</li> <li>b = 068</li> <li>...</li> <li>ab = 067068</li> <li>abc = 067068069</li> <li>abcd => i1= 067068069 and i2 = 070</li> </ul> <p>This way, for a 30 length string, I would require 10 ints.</p> <p>So 2 questions: 1- Would there be a better function to transform a 30 length string to a number, without ANY collision ?</p> <p>2- In the case there isn't, in a database filed with a million search terms, would it be better to compare 10 ints per item, or compare 30 length string per item ? Something like </p> <pre><code>Select from terms where i1 == search.i1 and i2 = search.i2 and ... i10 == search.i10 </code></pre> <p>OR</p> <pre><code>Select from terms where term like search.term </code></pre> <p>Thanks for your attention.</p>