Script:Speed Up Large Index Create or Rebuild by Maclean.liu email@example.com www.oracledatabase12g.com
About Mel Email:firstname.lastname@example.org Blog:www.oracledatabase12g.coml Oracle Certified Database Administrator Master 10gand 11gl Over 6 years experience with Oracle DBA technologyl Over 7 years experience with Linux technologyl Member Independent Oracle Users Groupl Member All China Users Groupl Presents for advanced Oracle topics: RAC,DataGuard, Performance Tuning and Oracle Internal.
www.oracledatabase12g.com-- Script Tested above 10g-- Create a new temporary segment tablespace specifically for creating theindex.-- CREATE TEMPORARY TABLESPACE tempindex tempfile filename SIZE 20G ;-- ALTER USER username TEMPORARY TABLESPACE tempindex;REM PARALLEL_EXECUTION_MESSAGE_SIZE can be increased to improve throughput.REM but need restart instance,and should be same in RAC environmentREM this doesnt make sense,unless high parallel degree-- alter system set parallel_execution_message_size=65535 scope=spfile;alter session set workarea_size_policy=MANUAL;alter session set workarea_size_policy=MANUAL;alter session set db_file_multiblock_read_count=512;alter session set db_file_multiblock_read_count=512;--In conclusion, in order to have the least amount of direct operations and--have the maximum possible read/write batches these are the parameters to set:alter session set events 10351 trace name context forever, level 128;REM set sort_area_size to 700M or 1.6 * table_sizeREM 10g bug need to set sort_area_size twiceREM remember large sort area size doesnt mean better performanceREM sometimes you should reduce below setting,and then sort may benefit fromdisk sortREM and attention to avoid PGA swapalter session set sort_area_size=734003200;alter session set sort_area_size=734003200;REM set sort area first,and then set SMRC for parallel slaveREM Setting this parameter can activate our previous setting of sort_area_sizeREM and we can have large sort multiblock read counts.alter session set "_sort_multiblock_read_count"=128;alter session set "_sort_multiblock_read_count"=128;alter session enable parallel ddl;create [UNIQUE] index ... [ONLINE] parallel [Np] nologging;alter index .. logging;alter index .. noparallel;--TRY below underscore parameter while poor performance--alter session set "_shrunk_aggs_disable_threshold"=100;REM _newsort_type=2 only works if the patch for bug:4655998 has been appliedREM The fix for bug:4655998 has been included in the 10.2.0.4 patchset.REM got worse in most cases--alter session set "_newsort_type" = 2;OR--alter session set "_newsort_enabled"=false; then useSort V1 algorithm,got worse in most casesrem !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!IMPORTANT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!