oracle - How to improve the SQL insert query performance? -
i getting long response time while querying data (83 million rows approx.) 1 table , inserting table in same schema. takes 1 , half hour. query looks below:
insert table_a ( dim_key, client_key, consumer_dim_key, prcs_wk ) ( (( (select dim_key, client_key, consumer_dim_key, prcs_wk (*select distinct dim_key, client_key, prcs_wk, consumer_dim_key, sum(sale_amount) over(partition consumer_dim_key) sale_amount fact_table dim_key = '300067' , criteria_id = '1234' , is_exists = 'n'* ) sale_amount > 0 ) union (select dim_key, client_key, consumer_dim_key, prcs_wk (*select distinct dim_key, client_key, prcs_wk, consumer_dim_key, sum(sale_amount) over(partition consumer_dim_key) sale_amount fact_table dim_key = '300067' , criteria_id = '1235' , is_exists = 'n'* ) sale_amount > 0 )) union (select dim_key, client_key, consumer_dim_key, prcs_wk (*select distinct dim_key, client_key, prcs_wk, consumer_dim_key, sum(sale_amount) over(partition consumer_dim_key) sale_amount fact_table dim_key = '300067' , criteria_id = '1236' , is_exists = 'n'* ) sale_amount > 0 )) )
here tables present in same schema. queries marked * returns number of rows as:
sub-query 1: 80 million rows sub-query 2: 3.1 million rows sub-query 3: 0.2 million row
- you can try use append hint make oracle write new data on hwm mark.
- if have indexes oracle wastes times have them up-do-date. can disable them , rebuild after insert finishes.
- also if there 83 millions rows insert generate lot of redo information. disable redo log generation of table use the nologging option:
alter table your_table nologging;
- also can use asynchronous writing online redo log
commit_wait
,commit_logging tips
- you can set job queue schedule long-running operation in background. read more use this
- you can use parallel dml
this suggestions can give without having explain plan.
Comments
Post a Comment