title: Oracle: take advantage of using two index
body: <p>As you can see Oracle could exploit two indexes and solve the entire query without accessing the table by rowid?</p>
  
  <pre><code>SELECT  'Scarti letture GAS' tipo, campo47 pdf, COUNT (1) n
    FROM out.CONSUMI_GEE_LC_T500_00 v
    WHERE stato = 'SC'
    AND stato is not null
    AND campo47 is not null
    GROUP BY 'Scarti letture GAS', campo47;
  </code></pre>
  
  <p>I've made a test adding the field campo47 to the STATO index. Performance boosts from 1' 49'' to 0,6s.</p>
  
  <p>Index on stato is not selective. Index on campo47 (it means field47) is really selective.</p>
  
  <p><img src="https://i.stack.imgur.com/m0MHh.png" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/eEBml.png" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/kUU25.png" alt="enter image description here"></p>