title: Query Performance while using Oracle aggregate function
body: <p>Below is the query in which I am using an aggregate function. The where clause is simple with an index on corpId and incoming_date .
  If I simply fetch all rows/count the query takes lesser than a second. However when I use the aggregate function the query takes about 4 minutes.
  I am using oracle 11i and the total rows the where clause retrieves is around 64000.  The table and index statistics have also been gathered recently and there are no new rows added in the table. </p>
  
  <p>Please suggest on improving the speed.</p>
  
  <pre><code>SELECT
  sum(paid_amt) totalamount
  FROM test_table e
  WHERE  e.corpId =6
  AND e. incoming_date &gt;= to_date('01-12-2012','dd-mm-yyyy')
  AND e. incoming _date &lt;= to_date('09-01-2013','dd-mm-yyyy')
  </code></pre>