国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > 幫助中心 > 正文

遠程數據庫的表超過20個索引的影響詳細解析

2024-07-09 22:41:31
字體:
來源:轉載
供稿:網友

昨天同事參加了一個研討會,有提到一個案例。一個通過dblink查詢遠端數據庫,原來查詢很快,但是遠端數據庫增加了一個索引之后,查詢一下子變慢了。

經過分析,發現那個通過dblink的查詢語句,查詢遠端數據庫的時候,是走索引的,但是遠端數據庫添加索引之后,如果索引的個數超過20個,就會忽略第一個建立的索引,如果查詢語句恰好用到了第一個建立的索引,被忽略之后,只能走Full Table Scan了。

聽了這個案例,我查了一下,在oracle官方文檔中,關于Managing a Distributed Database有一段話:

Several performance restrictions relate to access of remote objects:

Remote views do not have statistical data.
Queries on partitioned tables may not be optimized.
No more than 20 indexes are considered for a remote table.
No more than 20 columns are used for a composite index.

說到,如果遠程數據庫使用超過20個索引,這些索引將不被考慮。這段話,在oracle 9i起的文檔中就已經存在,一直到12.2還有。

那么,超過20個索引,是新的索引被忽略了?還是老索引被忽略了?如何讓被忽略的索引讓oracle意識到?我們來測試一下。
(本文基于12.1.0.2的遠程庫和12.2.0.1的本地庫進行測試,如果對測試過程沒興趣的,可以直接拉到文末看“綜上”部分)

(一)初始化測試表:

--創建遠程表:DROP TABLE t_remote; CREATE TABLE t_remote (col01 NUMBER,col02 NUMBER,col03 VARCHAR2(50),col04 NUMBER,col05 NUMBER,col06 VARCHAR2(50),col07 NUMBER,col08 NUMBER,col09 VARCHAR2(50),col10 NUMBER,col11 NUMBER,col12 VARCHAR2(50),col13 NUMBER,col14 NUMBER,col15 VARCHAR2(50),col16 NUMBER,col17 NUMBER,col18 VARCHAR2(50),col19 NUMBER,col20 NUMBER,col21 VARCHAR2(50),col22 NUMBER,col23 NUMBER,col24 VARCHAR2(50),col25 NUMBER,col26 NUMBER,col27 VARCHAR2(50));alter table t_remote modify (col01 not null);INSERT INTO t_remoteSELECTrownum, rownum, rpad('*',50,'*'),rownum, rownum, rpad('*',50,'*'),rownum, rownum, rpad('*',50,'*'),rownum, rownum, rpad('*',50,'*'),rownum, rownum, rpad('*',50,'*'),rownum, rownum, rpad('*',50,'*'),rownum, rownum, rpad('*',50,'*'),rownum, rownum, rpad('*',50,'*'),rownum, rownum, rpad('*',50,'*')FROM dualCONNECT BY level <= 10000;commit; create unique index t_remote_i01_pk on t_remote (col01);alter table t_remote add (constraint t_remote_i01_pk primary key (col01) using index t_remote_i01_pk);create index t_remote_i02 on t_remote (col02);create index t_remote_i03 on t_remote (col03);create index t_remote_i04 on t_remote (col04);create index t_remote_i05 on t_remote (col05);create index t_remote_i06 on t_remote (col06);create index t_remote_i07 on t_remote (col07);create index t_remote_i08 on t_remote (col08);create index t_remote_i09 on t_remote (col09);create index t_remote_i10 on t_remote (col10);create index t_remote_i11 on t_remote (col11);create index t_remote_i12 on t_remote (col12);create index t_remote_i13 on t_remote (col13);create index t_remote_i14 on t_remote (col14);create index t_remote_i15 on t_remote (col15);create index t_remote_i16 on t_remote (col16);create index t_remote_i17 on t_remote (col17);create index t_remote_i18 on t_remote (col18);create index t_remote_i19 on t_remote (col19);create index t_remote_i20 on t_remote (col20); exec dbms_stats.gather_table_stats(user,'T_REMOTE');
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 资中县| 长汀县| 长阳| 佛山市| 保亭| 广河县| 静乐县| 磐石市| 泰来县| 琼中| 许昌县| 乌鲁木齐县| 台安县| 太仆寺旗| 出国| 鄂尔多斯市| 洛宁县| 芷江| 洛川县| 彩票| 蚌埠市| 朝阳县| 平凉市| 新源县| 三门峡市| 分宜县| 康保县| 广灵县| 三都| 葫芦岛市| 海晏县| 乌鲁木齐市| 麦盖提县| 浠水县| 潞城市| 文化| 兴城市| 武宣县| 临汾市| 昆山市| 镇江市|