zoukankan      html  css  js  c++  java
  • oracle 11g SKIP_UNUSABLE_INDEXES参数

    SKIP_UNUSABLE_INDEXES的作用是在DML期间跳过对索引的维护,这样可以提交DML的效率,可以事后一次性重建,但是SKIP_UNUSABLE_INDEXES=y对unique index不起作用,因为此时的unique index扮演者constraint的作用所以在insert数据时index必须被更新。我们最近遇到个场景比较麻烦,使用sql load direct加载的数据,有一个id字段因为并行加载无法通过sequence生成唯一值,需要在加载完成后使用update set = seq.nextval生成序列号,但是update无法跳过唯一索引,也就是上面提到的。但是靠业务代码中drop/create index每个表硬编码太不现实、维护性也差,因为我们有数百处这样的逻辑,于是研究出了一个变通的方法,写个存储过程,首先查询某个表的所有唯一索引定义,将其删除,然后重建为非唯一索引并标记为unusable,这样索引定义在但是不维护,这么做的优点是索引定义保持了又不耗费时间,如下:

    select count(1) from ta_textparameter
    drop index idx_xx; --2500w记录
    create index idx_xx on ta_textparameter(l_rowid,c_tenantid,c_paramlevel,c_paramclass,c_paramitem,c_tacode,c_managercode,c_fundcode,c_agencyno) nologging;
    --166秒
    drop index idx_xx; --2500w记录
    create index idx_xx on ta_textparameter(l_rowid,c_tenantid,c_paramlevel,c_paramclass,c_paramitem,c_tacode,c_managercode,c_fundcode,c_agencyno) unusable nologging;
    --0.01秒

  • 相关阅读:
    React开发入门
    API爬虫--Twitter实战
    网页爬虫--scrapy入门
    爬虫入门(实用向)
    随谈10年的技术生涯和技术成长
    html元素的显示和隐藏
    Ubuntu下用cue文件对ape和wav文件自动分轨
    Bash内置命令exec和重定向
    Bash提示符
    Bash启动选项
  • 原文地址:https://www.cnblogs.com/zhjh256/p/9531690.html
Copyright © 2011-2022 走看看