Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>Oracle</code> <em>may</em> push predicate into a view if it thinks it will improve the plan.</p> <p>If you want to avoid this, you may use either of the following:</p> <ol> <li>Add a <code>/*+ NO_MERGE */</code> or <code>/*+ NO_PUSH_PRED */</code> hint into the view definition</li> <li>Add a <code>/*+ NO_MERGE (view) */</code> or <code>/*+ NO_PUSH_PRED (view) */</code> hint into the query that uses the view.</li> </ol> <p>If you want to force this, use their couterparts <code>/*+ PUSH_PRED */</code> and <code>/*+ MERGE */</code></p> <p>As long as performance is concerned, there is no difference between using a defined view (if it's not a <code>MATERIALIZED VIEW</code> of course) or an inline view (i. e. subquery).</p> <p><code>Oracle</code> compiles plans not for views, but for exact <code>SQL</code> texts.</p> <p>That is, for the following statements:</p> <pre><code>SELECT A, B, C FROM aTbl, bTbl LEFT JOIN cTbl ON bTbl.cTblID = cTbl.objectkey WHERE aTbl.objectkey = bTbl.parentkey AND aTbl.flag1 = :NUMBER SELECT * FROM ( SELECT A, B, C, flag1 FROM aTbl, bTbl LEFT JOIN cTbl ON bTbl.cTblID = cTbl.objectkey WHERE aTbl.objectkey = bTbl.parentkey ) WHERE flag1 = :NUMBER /* CREATE VIEW v_abc AS SELECT A, B, C, flag1 FROM aTbl, bTbl LEFT JOIN cTbl ON bTbl.cTblID = cTbl.objectkey WHERE aTbl.objectkey = bTbl.parentkey */ SELECT A, B, C FROM v_abc WHERE flag1 = :NUMBER </code></pre> <p>the plan will:</p> <ol> <li>Be the same (if <code>Oracle</code> will choose to push the predicate, which is more than probable); <ul> <li>Be compiled when first called;</li> <li>Be reused when called again.</li> </ul></li> </ol>
    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. 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.
 

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