title: Oracle 8i Exists query
body: <p>I am trying to speedup a query that is being run on a Oracle 8 server, against two tables that both have a few hundred thousands rows. The current query time varies from 12 to 30 seconds.</p>
  <p>This is the original query:</p>
  <pre><code>SELECT
      DISTINCT STOCK_ID
  FROM
      STOCK_MOVES
  WHERE
      ALTER_VAL IN (SELECT TO_CHAR(REZ) FROM REZ_TABLE WHERE NR_R = 1234)
  AND
      DOCUMENT_CAT = 11
  </code></pre>
  <p>I tried to change it to the following and the query time dropped a few seconds:</p>
  <pre><code>SELECT
     DISTINCT STOCK_ID
  FROM
     STOCK_MOVES, REZ_TABLE
  WHERE
     ALTER_VAL = TO_CHAR(REZ) AND NR_R = 1234
  AND
     DOCUMENT_CAT = 10                              
  </code></pre>
  <p>I am hoping that maybe if I try with EXISTS it will speed up but I don't know how to write the query. Any help will be greatly appreciated.</p>