title: Best way to select out of millions of rows in an Oracle DB
body: <p>G'day!</p>
  
  <p>I have one million different words which I'd like to query for in a table with 15 million rows. The result of synonyms together with the word is getting processed after each query.</p>
  
  <p>table looks like this:</p>
  
  <pre><code>    synonym      word
      ---------------------
      ancient      old
      anile        old
      centenarian  old
      darkened     old
      distant      far
      remote       far
      calm         gentle
      quite        gentle
  </code></pre>
  
  <p>This is how it is done in Java currently:</p>
  
  <pre><code>....
  PreparedStatement stmt;
  ResultSet wordList;
  ResultSet syns;
  ...
  
  stmt = conn.prepareStatement("select distinct word from table");
  wordList = stmt.executeQuery();
  
  while (wordList.next()) {
      stmt = conn.prepareStatement("select synonym from table where word=?");
      stmt.setString(1, wordList.getString(1));
      syns = stmt.executeQuery();
  
      process(syns, wordList.getString(1));
  }
  ...
  </code></pre>
  
  <p>This is incredible slow. What's the fastest way to do stuff like this?</p>
  
  <p>Cheers,
  Chris</p>