title: Query with more results works fine but with less results taking time
body: <pre><code>SELECT COUNT(*) AS ct
  FROM TABLEA _tablea
  LEFT OUTER JOIN
    (SELECT DISTINCT CM_CASE_ID,
      LOG_TIMESTAMP,
      ACTION_PERFORMED_BY,
      CASE_FOLLOW_UP_DATE,
      ACTION_PICKLIST_ID,
      CASE_REQUEST_NOTE_VALUE,
      CASE_STATUS_ID,
      RESOLUTION_PICKLIST_ID,
      PREVIOUS_REQUEST_OWNER,
      CURRENT_REQUEST_OWNER,
      CASE_FOLLOW_UP_NOTE_VALUE,
      CM_PENDING_REASON_ID,
      ACCOUNT_STATUS
    FROM TABLEB _tableb
    WHERE _tableb.LOG_TIMESTAMP
      ||_tableb.CM_CASE_ID IN
      (SELECT MIN(_tableb.LOG_TIMESTAMP)
        ||_tableb.CM_CASE_ID AS col_0_0_
      FROM TABLEB _tableb
      WHERE _tableb.CASE_STATUS_ID='A'
      GROUP BY _tableb.CM_CASE_ID
      )
    ) _tableb
  ON _tablea.CM_CASE_ID=_tableb.CM_CASE_ID
  WHERE _tablea.CASE_CREATION_DATE BETWEEN to_date('12/01/2016', 'mm/dd/yyyy') AND to_date('06/07/2017', 'mm/dd/yyyy') + 1
  AND _tablea.CASE_REQUEST_TYPE                                                                                       IN (1,2,3)
  AND _tablea.CASE_STATUS_ID                                                                                          IN ('A','B')       
  </code></pre>
  
  <p>the above query which expects records between 12/01/2016 and 06/07/2017 is work fine in less time</p>
  
  <pre><code>SELECT COUNT(*) AS ct
  FROM TABLEA _tablea
  LEFT OUTER JOIN
    (SELECT DISTINCT CM_CASE_ID,
      LOG_TIMESTAMP,
      ACTION_PERFORMED_BY,
      CASE_FOLLOW_UP_DATE,
      ACTION_PICKLIST_ID,
      CASE_REQUEST_NOTE_VALUE,
      CASE_STATUS_ID,
      RESOLUTION_PICKLIST_ID,
      PREVIOUS_REQUEST_OWNER,
      CURRENT_REQUEST_OWNER,
      CASE_FOLLOW_UP_NOTE_VALUE,
      CM_PENDING_REASON_ID,
      ACCOUNT_STATUS
    FROM TABLEB _tableb
    WHERE _tableb.LOG_TIMESTAMP
      ||_tableb.CM_CASE_ID IN
      (SELECT MIN(_tableb.LOG_TIMESTAMP)
        ||_tableb.CM_CASE_ID AS col_0_0_
      FROM TABLEB _tableb
      WHERE _tableb.CASE_STATUS_ID='A'
      GROUP BY _tableb.CM_CASE_ID
      )
    ) _tableb
  ON _tablea.CM_CASE_ID=_tableb.CM_CASE_ID
  WHERE _tablea.CASE_CREATION_DATE BETWEEN to_date('05/01/2017', 'mm/dd/yyyy') AND to_date('06/07/2017', 'mm/dd/yyyy') + 1
  AND _tablea.CASE_REQUEST_TYPE                                                                                       IN (1,2,3)
  AND _tablea.CASE_STATUS_ID   IN ('A','B')   
  </code></pre>
  
  <p>this query which expects records between 05/01/2017 and 06/07/2017  is taking too much time around 20 minutes...</p>
  
  <p>Pls help out why the query which expect more result working fine and less not.</p>