Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The explain plans are different: a single <code>MIN</code> or <code>MAX</code> will produce a <code>INDEX FULL SCAN (MIN/MAX)</code> whereas when the two are present you will get an <code>INDEX FULL SCAN</code> or a <a href="http://docs.oracle.com/cd/E11882_01/server.112/e25789/indexiot.htm#sthref320" rel="nofollow"><code>FAST FULL INDEX SCAN</code></a>.</p> <p>To understand the difference, we have to look for a description of a <a href="http://docs.oracle.com/cd/E11882_01/server.112/e25789/indexiot.htm#CNCPT88838" rel="nofollow"><code>FULL INDEX SCAN</code></a>:</p> <blockquote> <p>In a full index scan, the database reads the entire index in order.</p> </blockquote> <p>In other words, if the index is on a <code>VARCHAR2</code> field, Oracle will fetch the first block of the index that would contain for example all entries that start with the letter "A" and will read block by block all entries alphabetically until the last entry ("A" to "Z"). Oracle can process in this way because the entries are sorted in a binary tree index.</p> <p>When you see <code>INDEX FULL SCAN (MIN/MAX)</code> in an explain plan, that is the result of an optimization that uses the fact that since the entries are sorted, you can stop after having read the first one if you are only interested by the <code>MIN</code>. If you are interested in the <code>MAX</code> only, Oracle can use the same access path but this time starting by the last entry and reading backwards from "Z" to "A".</p> <p>As of now, a <code>FULL INDEX SCAN</code> has only one direction (either forward or backward) and can not start from both ends simultaneously, this is why when you ask for both the min and the max, you get a less efficient access method.</p> <p>As suggested by other answers, if the query needs critical efficiency, you could run your own optimization by searching for the min and the max in two distinct queries.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload