11.2新特性之不可見索引-臨時統計資訊
Oracle11.2透過增加部分物件的會話級可見性/屬性,支援更靈活得維護、開發。
比如新增了editionable物件,不可見索引(invisible index),不可見統計資訊(pending statistics),分別驗證如下。
1,支援editionable的物件型別:
同義詞
檢視
函式
過程
包
型別
庫
觸發器
測試如下:
Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.1.0
Connected as
SQL> desc t
Name Type Nullable Default Comments
---- ------- -------- ------- --------
A INTEGER Y
B INTEGER Y
C INTEGER Y
SQL> alter user mh enable editions;
User altered
SQL> create edition test_ed;
Done
SQL>
SQL> select sys_context('userenv','current_edition_name') from dual;
SYS_CONTEXT('USERENV','CURRENT
--------------------------------------------------------------------------------
ORA$BASE
SQL> create editioning view vt
2 a
3
SQL>
SQL> create editioning view vt
2 as
3 select a,b from t;
View created
SQL> alter session set edition=test_ed;
Session altered
SQL> create editioning view vt
2 as
3 select a,b,c from t;
create editioning view vt
as
select a,b,c from t
ORA-00955: 名稱已由現有物件使用
SQL> create or replace editioning view vt
2 as
3 select a,b,c from t;
View created
SQL> desc vt;
Name Type Nullable Default Comments
---- ------- -------- ------- --------
A INTEGER Y
B INTEGER Y
C INTEGER Y
SQL> alter session set edition=ora$base;
Session altered
SQL> desc vt;
Name Type Nullable Default Comments
---- ------- -------- ------- --------
A INTEGER Y
B INTEGER Y
SQL> alter session set edition=test_ed;
Session altered
SQL> desc vt;
Name Type Nullable Default Comments
---- ------- -------- ------- --------
A INTEGER Y
B INTEGER Y
C INTEGER Y
SQL> drop view vt;
View dropped
SQL> desc vt;
Object vt does not exist.
SQL> alter session set edition=ora$base;
Session altered
SQL> desc vt;
Name Type Nullable Default Comments
---- ------- -------- ------- --------
A INTEGER Y
B INTEGER Y
SQL> drop edition test_ed;
Done
SQL>
SQL> desc user_objects;
Name Type Nullable Default Comments
-------------- ------------- -------- ------- ----------------------------------------------------------------------------
OBJECT_NAME VARCHAR2(128) Y Name of the object
SUBOBJECT_NAME VARCHAR2(30) Y Name of the sub-object (for example, partititon)
OBJECT_ID NUMBER Y Object number of the object
DATA_OBJECT_ID NUMBER Y Object number of the segment which contains the object
OBJECT_TYPE VARCHAR2(19) Y Type of the object
CREATED DATE Y Timestamp for the creation of the object
LAST_DDL_TIME DATE Y Timestamp for the last DDL change (including GRANT and REVOKE) to the object
TIMESTAMP VARCHAR2(19) Y Timestamp for the specification of the object
STATUS VARCHAR2(7) Y Status of the object
TEMPORARY VARCHAR2(1) Y Can the current session only see data that it place in this object itself?
GENERATED VARCHAR2(1) Y Was the name of this object system generated?
SECONDARY VARCHAR2(1) Y Is this a secondary object created as part of icreate for domain indexes?
NAMESPACE NUMBER Y Namespace for the object
EDITION_NAME VARCHAR2(30) Y Name of the edition in which the object is actual
2,不可見檢視
SQL> desc t;
Name Type Nullable Default Comments
---- ------- -------- ------- --------
A INTEGER Y
B INTEGER Y
C INTEGER Y
SQL> create index idx_t_a on t(a);
Index created
SQL> set autotrace on
Cannot SET AUTOTRACE
SQL> explain plan for select * from t where a=1;
Explained
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
Plan hash value: 1194865126
--------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Tim
--------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 39 | 1 (0)| 00:
| 1 | TABLE ACCESS BY INDEX ROWID| T | 1 | 39 | 1 (0)| 00:
|* 2 | INDEX RANGE SCAN | IDX_T_A | 1 | | 1 (0)| 00:
--------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("A"=1)
Note
-----
- dynamic sampling used for this statement (level=2)
18 rows selected
SQL> alter index idx_t_a invisible;
Index altered
SQL> explain plan for select * from t where a=1;
Explained
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
Plan hash value: 1601196873
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 39 | 2 (0)| 00:00:01 |
|* 1 | TABLE ACCESS FULL| T | 1 | 39 | 2 (0)| 00:00:01 |
--------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("A"=1)
Note
-----
- dynamic sampling used for this statement (level=2)
17 rows selected
SQL> select visibility from user_indexes where table_name='T';
VISIBILITY
----------
INVISIBLE
SQL> show parameter visible
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
optimizer_use_invisible_indexes boolean FALSE
SQL> alter session set optimizer_use_invisible_indexes=true;
Session altered
SQL> explain plan for select * from t where a=1;
Explained
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
Plan hash value: 1194865126
--------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Tim
--------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 39 | 1 (0)| 00:
| 1 | TABLE ACCESS BY INDEX ROWID| T | 1 | 39 | 1 (0)| 00:
|* 2 | INDEX RANGE SCAN | IDX_T_A | 1 | | 1 (0)| 00:
--------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("A"=1)
Note
-----
- dynamic sampling used for this statement (level=2)
18 rows selected
3,PENDING STATISTICS
SQL> show parameter pending
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
optimizer_use_pending_statistics boolean FALSE
SQL> select num_rows from user_tables where table_name='T';
NUM_ROWS
----------
SQL> exec dbms_stats.set_table_prefs(user,'T','PUBLISH','false');
PL/SQL procedure successfully completed
SQL> exec dbms_stats.gather_table_stats(user,'T');
SQL>
PL/SQL procedure successfully completed
SQL>
SQL> select num_rows from user_tables where table_name='T';
NUM_ROWS
----------
SQL> exec dbms_stats.publish_pending_stats(user,'T');
PL/SQL procedure successfully completed
SQL> select num_rows from user_tables where table_name='T';
NUM_ROWS
----------
0
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/18922393/viewspace-752084/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 8.0新特性-不可見索引索引
- 11g新特性: 索引不可見(Index Invisible)索引Index
- Oracle之不可見索引Oracle索引
- oracle 12c 新特性之不可見欄位Oracle
- 11g新特性:不可視索引索引
- oracle 12C 新特性之臨時undo控制Oracle
- ORACLE19c新特性-實時統計資訊收集Oracle
- Oracle11.2新特性之儲存Oracle
- 【索引】Oracle之不可見索引和虛擬索引的比對索引Oracle
- Oracle之不可見索引(invisible indexes)Oracle索引Index
- Oracle 11g新特性之收集多列統計資訊Oracle
- Oracle12C新特性_不可見欄位(二)Oracle
- oracle12c新特性(3)-不可見欄位Oracle
- Oracle 12c 新特性之臨時Undo--temp_undo_enabledOracle
- SQL優化之統計資訊和索引SQL優化索引
- Oracle11.2新特性之listagg函式Oracle函式
- 11G新特性,比較統計資訊
- 11G新特性,待定的統計資訊
- 新的Oracle時間資訊特性Oracle
- MySQL 5.7 新特性 共享臨時表空間及臨時表改進MySql
- MySQL8.0新特性-臨時表的改善MySql
- oracle12c新特性(5)- 臨時undoOracle
- ORACLE表統計資訊與列統計資訊、索引統計資訊Oracle索引
- Oracle 12c新特性之檢測有用的多列統計資訊Oracle
- 【INDEX】11g中利用不可見索引降低索引維護時對系統的衝擊Index索引
- oracle10G新特性之臨時表空間組的應用Oracle
- 19C新特性研究實時統計
- Oracle11.2表分割槽新特性Oracle
- 全域性臨時表GTT的統計資訊收集辦法:
- oracle外部表建立以及收集統計資訊以及臨時表Oracle
- Oracle 12c 新特性 - 臨時表undo(TEMP UNDO)Oracle
- 關於不可見索引的學習索引
- Oracle 11g 建立臨時window時間視窗 收集統計資訊Oracle
- Oracle 11g新特性:多列統計資訊(MultiColumn Statistics)Oracle
- 23c 新特性之實時SQL計劃管理SQL
- Oracle12c中效能最佳化&功能增強新特性之臨時undoOracle
- 【Mysql】MySQL 5.7新特性之Generated Column(函式索引)MySql函式索引
- oracle 12c 新特性 Temporary UNDO 臨時回滾段Oracle