使用NOSEGMENT创建测试索引

发布时间:2020-08-11 03:11:36 作者:jsj_007
来源:网络 阅读:211

如果你想要创建一个很大的索引,但并不想给它分配空间,而是要先确定优化器是否会选择使用该索引,那么在11g中可以使用NOSEGMENT来创建索引就可以先进行测试。如果确定了这个索引是有用的,可以删除该索引,然后使用不包含NOSEGMENT的语句重建它。

SQL> create index idx_emp on emp(employee_id) nosegment;

Index created.

SQL> set autot traceonly;
SQL> select * from APP.EMP t where t.employee_id='105';

Execution Plan
----------------------------------------------------------
Plan hash value: 3956160932

--------------------------------------------------------------------------
| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |      |     1 |   133 |     3   (0)| 00:00:01 |
|*  1 |  TABLE ACCESS FULL| EMP  |     1 |   133 |     3   (0)| 00:00:01 |
--------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   1 - filter("T"."EMPLOYEE_ID"=105)

Note
-----
   - dynamic sampling used for this statement (level=2)


Statistics
----------------------------------------------------------
          4  recursive calls
          0  db block gets
         10  consistent gets
          0  physical reads
          0  redo size
       1305  bytes sent via SQL*Net to client
        519  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
          1  rows processed

SQL> set autot off

SQL> ALTER SESSION SET "_use_nosegment_indexes"=true;  <----session级修改隐含参数_use_nosegment_indexes为true

Session altered.

SQL>  set autot traceonly;
SQL> set lines 900
SQL> select * from APP.EMP t where t.employee_id='105';


Execution Plan
----------------------------------------------------------
Plan hash value: 306890541

---------------------------------------------------------------------------------------
| Id  | Operation                   | Name    | Rows  | Bytes | Cost (%CPU)| Time     |
---------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT            |         |     1 |   133 |     2   (0)| 00:00:01 |
|   1 |  TABLE ACCESS BY INDEX ROWID| EMP     |     1 |   133 |     2   (0)| 00:00:01 |
|*  2 |   INDEX RANGE SCAN          | IDX_EMP |     1 |       |     1   (0)| 00:00:01 |
---------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - access("T"."EMPLOYEE_ID"=105)

Note
-----
   - dynamic sampling used for this statement (level=2)


Statistics
----------------------------------------------------------
          0  recursive calls
          0  db block gets
          5  consistent gets
          0  physical reads
          0  redo size
       1305  bytes sent via SQL*Net to client
        519  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
          1  rows processed




推荐阅读:
  1. MongoDB索引管理——创建索引,查看索引,删除索引,重建
  2. MySQL 主键、索引创建

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

use nosegment inde

上一篇:好程序员Web前端中的js能运用到哪些方面

下一篇:PostgreSQL学习的九层宝塔

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》