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/