案例九
点击(此处)折叠或打开
- --执行drop_customers_indexes.sql, 删除除主键索引外的所有索引.
- sh@TESTDB11>@drop_customers_indexes.sql
-
- --在2个列上分别创建索引
- CREATE INDEX idx_cust_last_name ON customers(cust_last_name) NOLOGGING COMPUTE STATISTICS;
- CREATE INDEX idx_cust_first_name ON customers(cust_first_name) NOLOGGING COMPUTE STATISTICS;
-
- --query10.sql
- --优化程序可以同时使用这2个索引,但最终的成本不如使用复合索引低.
- SET ECHO ON
- SET TIMING ON
- SET AUTOTRACE TRACEONLY
- SET PAGESIZE 1000
-
- @flush.sql
- SELECT /*+ INDEX_JOIN(c idx_cust_first_name idx_cust_last_name) */ c.cust_last_name, c.cust_first_name FROM customers c;
-
- SET TIMING OFF
- SET AUTOTRACE OFF
-
- --执行query10.sql
- sh@TESTDB11>@query10.sql
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/17013648/viewspace-1072710/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/17013648/viewspace-1072710/