创建索引时的nologging效果

本文通过实验展示了在Oracle数据库中使用nologging选项创建索引可以显著提高创建速度并减少产生的redo日志量。对于包含162万条记录的表,不使用nologging创建索引耗时33.953秒,产生redo29777716;而使用nologging后,耗时缩短到13.328秒,产生的redo减少到228052。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

创建索引时使用nologging选项可以加快速度,节省时间,减少产生的日志量。

SQL> select count(*) from idx_test;

  COUNT(*)
----------
   1620416

Executed in 4.453 seconds

SQL> select value from v$sysstat t where name='redo size';

     VALUE
----------
 243558888

Executed in 0.015 seconds

SQL> create index idx_object_id on idx_test(object_id);

Index created

Executed in 33.953 seconds

SQL> select value from v$sysstat t where name='redo size';

     VALUE
----------
 273336604

Executed in 0.031 seconds

SQL> select 273336604-243558888 from dual;

273336604-243558888
-------------------
           29777716

Executed in 0.031 seconds

SQL> drop index idx_object_id;

Index dropped

Executed in 0.516 seconds

SQL> select value from v$sysstat t where name='redo size';

     VALUE
----------
 273408596

Executed in 0.047 seconds

SQL> create index idx_object_id on idx_test(object_id) nologging;

Index created

Executed in 13.328 seconds

SQL> select value from v$sysstat t where name='redo size';

     VALUE
----------
 273636648

Executed in 0.031 seconds

SQL> select 273636648-273408596 from dual;

273636648-273408596
-------------------
             228052

Executed in 0.047 seconds

SQL>

从上面实验可以看出,一个1620416条记录的表,在不使用nologging的情况下,创建索引耗时33.953 秒,产生redo 29777716 ,使用nologging后,耗时13.328 秒,产生redo 228052。效果还是比较明显。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/517786/viewspace-661557/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/517786/viewspace-661557/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值