您的位置:首页 > 博客中心 > 数据库 >

oracle 如何预估将要创建的索引的大小

时间:2022-03-14 10:12

11.2.0.3.0create table test_index_size as select * from dba_objects;

EXEC DBMS_STATS.gather_table_stats(ownname => ‘SYS‘,tabname => ‘TEST_INDEX_SIZE‘);

declare

  l_index_ddl       varchar2(1000);

  l_used_bytes      number;

  l_allocated_bytes number;

begin

  dbms_space.create_index_cost(ddl         => ‘create index idx_t on sys.test_index_size(object_id) ‘,

                               used_bytes  => l_used_bytes,

                               alloc_bytes => l_allocated_bytes);

  dbms_output.put_line(‘used= ‘ || l_used_bytes || ‘bytes‘ ||

                       ‘     allocated= ‘ || l_allocated_bytes || ‘bytes‘);

end;

/

used= 383105bytes     allocated= 2097152bytes

:  used_bytes  explain plan for create indexOracle(estimated index size)  - estimated index size: 2097K bytes

   2097152

预估索引大小之前必须对表进行分析过。

 

本类排行

今日推荐

热门手游