首页 > 数据库 > Oracle > oracle 一条简单sql的优化

1、--估算索引大小:
4.6G 现有空间12G, 估算建完后还剩余7G 使用率(85-7)/85*100%=91.7%,会触发告警因此需要加空间
set serverout on
variable used_bytes number
variable alloc_bytes number
exec dbms_space.create_index_cost('create index i_vou_info_batch_cust_no on t_vou_XXXX( batch_no ,customer_no ) tablespace TBS_VOUCHER_IDX local online parallel 16',:used_bytes,:alloc_bytes);
print :used_bytes
print :alloc_bytes
create index i_vou_info_batch_cust_no on t_vou_XXXX( batch_no ,customer_no ) tablespace TBS_VOUCHER_IDX local online parallel 8;
alter index i_vou_info_batch_cust_no noparallel;
3、invisible原有的索引:
alter index I_VOU_INFO_BATCH_NO invisible;
4、观察是否使用新建的索引,及前后的性能变化:
5、删除原有的索引:
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/30109892/viewspace-2102641/ ,如需转载,请注明出处,否则将追究法律责任。