Improve Oracle indexes

– Build faster, smaller and better-balanced indexes[@more@]

When using the create index syntax to build and Oracle index, there are many options that can dramatically improve the speed of the creation, the space used by the index, and the height of the resulting index.

Let’s review a few of these factors:

Speed Factors

Parallel option – This option allows for parallel processes to scan the table. When an index is created, Oracle must first collect the symbolic key/ROWID pairs with a full-table scan. By making the full-table scan run in parallel, the index creation will run many times faster, depending on the number of CPUs, table partitioning and disk configuration. I recommend a n-1 for the degree option, where n is the number of CPUs on your Oracle server. In this example we create an index on a 36 CPU server and the index create twenty times faster:

CREATE INDEX cust_dup_idx
ON customer(sex, hair_color, customer_id)
PARALLEL 35;

Nologging option – The nologging option bypasses the writing of the redo log, significantly improving performance. The only danger with using nologging is that you must re-run the create index syntax if you performance a roll-forward database recovery. Using nologging with create index can speed index creation by up to 30%

CREATE INDEX cust_dup_idx
ON customer(sex, hair_color, customer_id)
PARALLEL 35
NOLOGGING;

Space & structure Factors

Compress option – The compress option is used to repress duplication of keys in non-unique indexes. For concatenated indexes (indexes with multiple columns), the compress option can reduce the size of the index by more than half. The compress option allows you to specify the prefix length for multiple column indexes. In this example we have a non-unique index on several low cardinality columns (sex and hair_color), and a high cardinality column (customer_id):

CREATE INDEX cust_dup_idx
ON customer(sex, hair_color, customer_id)
PARALLEL 35
NOLOGGING
COMPRESS 2;

Tablespace blocksize option – The blocksize of the index tablespace will have a huge impact on the structure of the index. For details, read Proof that large indexes reduce IO. Here is an example of an index created in a 32k tablespace:

create tablespace 23k_ts
datafile ‘/u01/app/oracle/prod/oradata/32k_file.dbf’
bocksize 32k;
CREATE INDEX cust_dup_idx
ON customer(sex, hair_color, customer_id)
PARALLEL 35
NOLOGGING
COMPRESS 2
TABLESPACE 32k_ts;

In sum,. There are many parameters that you can use to improve the performance of Oracle index creation, the size of the index tree and the height of the tree structure.

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

转载于:http://blog.itpub.net/8683736/viewspace-911942/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值