Thanks for the question, Shiv.
Asked: January 28, 2016 - 10:54 am UTC
Last updated: February 01, 2016 - 11:20 am UTC
Version: 11r
Viewed 1000+ times
ALTER MATERIALIZED VIEW EmployeeConfid55 DISABLE;
SQL> create table t as 2 select rownum x from dual connect by level <= 1000; Table created. SQL> SQL> create materialized view mv 2 enable query rewrite as 3 select count(*) from t; Materialized view created. SQL> SQL> set autotrace trace exp SQL> select count(*) from t; Execution Plan ---------------------------------------------------------- Plan hash value: 572630632 ------------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 3 | 3 (0)| 00:00:01 | | 1 | MAT_VIEW REWRITE ACCESS FULL| MV | 1 | 3 | 3 (0)| 00:00:01 | ------------------------------------------------------------------------------------- SQL> SQL> alter materialized view mv disable query rewrite; Materialized view altered. SQL> SQL> select count(*) from t; Execution Plan ---------------------------------------------------------- Plan hash value: 2966233522 ------------------------------------------------------------------- | Id | Operation | Name | Rows | Cost (%CPU)| Time | ------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 3 (0)| 00:00:01 | | 1 | SORT AGGREGATE | | 1 | | | | 2 | TABLE ACCESS FULL| T | 1000 | 3 (0)| 00:00:01 | ------------------------------------------------------------------- SQL> SQL> alter materialized view mv enable query rewrite; Materialized view altered. SQL> SQL> select count(*) from t; Execution Plan ---------------------------------------------------------- Plan hash value: 572630632 ------------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 3 | 3 (0)| 00:00:01 | | 1 | MAT_VIEW REWRITE ACCESS FULL| MV | 1 | 3 | 3 (0)| 00:00:01 | ------------------------------------------------------------------------------------- SQL> SQL> alter session set query_rewrite_enabled = false; Session altered. SQL> SQL> select count(*) from t; Execution Plan ---------------------------------------------------------- Plan hash value: 2966233522 ------------------------------------------------------------------- | Id | Operation | Name | Rows | Cost (%CPU)| Time | ------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 3 (0)| 00:00:01 | | 1 | SORT AGGREGATE | | 1 | | | | 2 | TABLE ACCESS FULL| T | 1000 | 3 (0)| 00:00:01 | ------------------------------------------------------------------- SQL> SQL> alter session set query_rewrite_enabled = true; Session altered. SQL> SQL> select count(*) from t; Execution Plan ---------------------------------------------------------- Plan hash value: 572630632 ------------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 3 | 3 (0)| 00:00:01 | | 1 | MAT_VIEW REWRITE ACCESS FULL| MV | 1 | 3 | 3 (0)| 00:00:01 | ------------------------------------------------------------------------------------- SQL> select /*+ no_rewrite */count(*) from t; Execution Plan ---------------------------------------------------------- Plan hash value: 2966233522 ------------------------------------------------------------------- | Id | Operation | Name | Rows | Cost (%CPU)| Time | ------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 3 (0)| 00:00:01 | | 1 | SORT AGGREGATE | | 1 | | | | 2 | TABLE ACCESS FULL| T | 1000 | 3 (0)| 00:00:01 | -------------------------------------------------------------------
Shiv, January 29, 2016 - 11:48 am UTC
Shiv, January 29, 2016 - 12:15 pm UTC
Shiv, February 01, 2016 - 9:37 am UTC
where insert_date >= add_months(sysdate, -1)
Need more information on hints? Check out the complete hint descriptions