title: IP number lookup in startIPNum and endIPNum range with Performance Optimization for Hibernate
body: <p>I have table with ID, startIPNum and endIPNum. startIPNum and endIPNum are already converted long numbers not IP strings.</p>
  
  <p>Following query works and takes somewhere between 3000 and 3200 ms</p>
  
  <pre><code> List&lt;GeoIP&gt; oneResult = new LinkedList(getHibernateTemplate().find(
              "from GeoIP where "+ipNum+" &gt;= startIpNum and "+ipNum+" &lt;= endIpNum"));
  </code></pre>
  
  <p>This query works and takes somewhere between 3000 to 4700 ms     </p>
  
  <pre><code>List&lt;GeoIP&gt; oneResult = new LinkedList(getHibernateTemplate().find(
              "from GeoIP where "+ipNum+" between startIpNum and endIpNum"));
  </code></pre>
  
  <p>The question is: is there a way to optimize this lookup to take a lot less time? The table has over 3'500'000 records.</p>