Create table as select (CTAS)statement is taking very long time.
tarunshAug 12 2011 — edited Sep 5 2011Hi All,
One of my procedure run a create table as select statement every month.
Usually it finishes in 20 mins. for 6172063 records and 1 hour in 13699067.
But this time it is taking forever even for 38076 records.
When I checked all it is doing is CPU usage. No I/O.
I did a count(*) using the query it brought results fine.
BUT CTAS keeps going on.
I'm using Oracle 10.2.0.4 .
main table temp_ip has 38076
table nhs_opcs_hier has 26769 records.
and table nhs_icd10_hier has 49551 records.
-------------------
Query is as follows:
create table analytic_hes.temp_ip_hier as
select b.*, (select nvl(max(hierarchy), 0)
from ref_hd.nhs_opcs_hier a
where fiscal_year = b.hd_spell_fiscal_year
and a.code in
(primary_PROCEDURE, secondary_procedure_1, secondary_procedure_2,
secondary_procedure_3, secondary_procedure_4, secondary_procedure_5,
secondary_procedure_6, secondary_procedure_7, secondary_procedure_8,
secondary_procedure_9, secondary_procedure_10,
secondary_procedure_11, secondary_procedure_12)) as hd_procedure_hierarchy,
(select nvl(max(hierarchy), 0) from ref_hd.nhs_icd10_hier a
where fiscal_year = b.hd_spell_fiscal_year
and a.code in
(primary_diagnosis, secondary_diagnosis_1,
secondary_diagnosis_2, secondary_diagnosis_3,
secondary_diagnosis_4, secondary_diagnosis_5,
secondary_diagnosis_6, secondary_diagnosis_7,
secondary_diagnosis_8, secondary_diagnosis_9,
secondary_diagnosis_10, secondary_diagnosis_11,
secondary_diagnosis_12, secondary_diagnosis_13,
secondary_diagnosis_14)) as hd_diagnosis_hierarchy
from analytic_hes.temp_ip b
-----------------
Any help would be greatly appreciated