在聚簇索引上建立索引的办法来优化多表连接!

多表连接速度慢,试着在两个表上建立cluster。

两个表还不在同一个 schema下面:

试着将他们建立在同一个schema下面,

SQL> create table cmdb.configuration_item_cluster1 cluster monitor_items_cluster(target_cs_uuid) as select
2 * from cmdb.configuration_item;
create table cmdb.configuration_item_cluster1 cluster monitor_items_cluster(target_cs_uuid) as select
*
ERROR at line 1:
ORA-00945: specified clustered column does not exist

SQL> drop cluster avail.monitor_items_cluster;
drop cluster avail.monitor_items_cluster
*
ERROR at line 1:
ORA-00943: cluster does not exist


SQL> drop index monitor_items_cluster_index;

Index dropped.

SQL> drop cluster monitor_items_cluster;
drop cluster monitor_items_cluster
*
ERROR at line 1:
ORA-00951: cluster not empty

SQL> drop cluster monitor_items_cluster including tables;

Cluster dropped.

用下面的办法建立CLUSTER.

CREATE CLUSTER monitor_items_cluster(target_cs_uuid varchar2(64))SIZE 1024;
CREATE INDEX monitor_items_cluster_index ON CLUSTER monitor_items_cluster;
create table monitor_items_cluster1 cluster monitor_items_cluster(target_cs_uuid) as select * from avail.monitor_items ;
create table configuration_item_cluster1 cluster monitor_items_cluster(uuid) as select * from cmdb.configuration_item;

然后修改查询使用cluster 表,再查看执行计划和执行时间,看是否性能有所提高。

你可能感兴趣的:(索引)