Reputation: 685
Creation of a PK and index on 880 mio rows takes about 1:15 hrs.
Query:
alter table STG.NOTES add constraint PK_NOTES primary key (NOTES_SK);
create unique index STG.BK_NOTES on STG.NOTES (NOTE_NBR ASC);
Is there a way to speed this up? I read of parallel and nologging options. The Oracle Server has 2 CPUs, so parallel (n-1 = 2-1 = 1) wont help. Leaving only nologging. What can you tell me about it? What is the trade off? Why would/wouldn't you use it?
edit: maybe I also need to explain what the context of index creation is:
truncate target table, then drop PK and index on target table
select from source and bulk insert into target
create index and PK on target table (= 1:15 hrs)
Upvotes: 2
Views: 2643
Reputation: 36807
NOSORT If NOTE_NBR
is already ordered you can save time
by not sorting the data. This may be true if NOTE_NBR is created from a single-threaded sequence or if your query is ordered.
Don't re-gather index statistics Creating or rebuilding indexes automatically creates the index statistics. If you re-gather statistics on the
table, cascade=>false
can save some time. The default option, cascade=>dbms_stats.auto_cascade
does not really work.
Upvotes: 0
Reputation: 9759
Actually you can use a higher degree of parallelism on a pc with 2 cores. check the parallel_max_servers
for the default setting in you db.
show parameter parallel_max_servers
To perform in parallel you can use
alter session force parllel ddl parallel 4
8 slaved will be created in addition to the coordinator.
About nologging
,I think it's a good option. using nologging
means that in the event of a disaster you'll have to recreate your indexes. If the index creation process is a routine, you can consider it.
Upvotes: 1