oracle - How to optimise this SQL Query -
this query taking more 4 minutes
, want make run more quickly. please provide suggestions
select * fact_acct zz zz.c_acctschema_id=1000000 , zz.postingtype ='a' , trunc(zz.dateacct,'dd') between to_date('2016-01-01','yyyy-mm-dd') , to_date('2016-01-01','yyyy-mm-dd') , z_id_cpt_to_val(account_id) <= z_id_cpt_to_val(1001508) , z_id_cpt_to_val(account_id) >= z_id_cpt_to_val(1001508)
the function z_id_cpt_to_val ()
cause of problem, it's run in sql queries, take long time
because if retire last 2 lines ,this sql give results in 3 secondes
so, ideas optimise that
thanks
without plan , ddl on table assumption.
first assumption
you have index on fact_acct.dateacct, trunc(fact_acct.dateacct,'dd') - not use index trunc(fact_acct.dateacct,'dd') trim hour/ minutes/ seconds part. can use
zz.dateacct >= between to_date('2016-01-01','yyyy-mm-dd') <to_date('2016-01-02','yyyy-mm-dd')
second assumption
instead of
z_id_cpt_to_val(account_id) <= z_id_cpt_to_val(1001508)
put
(select z_id_cpt_to_val(account_id) dual) <= (select z_id_cpt_to_val(1001508) dual)
oracle doesn't execute functions every time insted uses caching mechanism. carefull! if want oracle executes z_id_cpt_to_val, don't need approach
Comments
Post a Comment