dbTalk Databases Forums  

After table analyzed query runs 8 hours longer

comp.databases.oracle.server comp.databases.oracle.server


Discuss After table analyzed query runs 8 hours longer in the comp.databases.oracle.server forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Patrick Burns
 
Posts: n/a

Default After table analyzed query runs 8 hours longer - 09-17-2004 , 02:59 PM






All of our database tables are analyzed with the exception of 1. The
queries run in Choose mode and when we analyze that one table a query
goes from 1.5 hours to 9.5 hours. All of the other queries run faster
but this one. I have tried creating all kinds of indexes with no
success.

----the table in question is analyzed here (MF_AJ - 40 millon
rows)-----
SELECT STATEMENT Cost=258592081
SORT UNIQUE
UNION-ALL
SORT GROUP BY
HASH JOIN
TABLE ACCESS FULL MF_SYS_STGS
NESTED LOOPS
HASH JOIN
INDEX FAST FULL SCAN I3_ST_EXP_AUTY_MNTN
TABLE ACCESS FULL MF_AJ
TABLE ACCESS BY INDEX ROWID MF_TJ
INDEX UNIQUE SCAN PK_TJ
SORT GROUP BY
HASH JOIN
HASH JOIN
TABLE ACCESS FULL MF_SYS_STGS
NESTED LOOPS
HASH JOIN
INDEX FAST FULL SCAN I3_ST_EXP_AUTY_MNTN
TABLE ACCESS FULL MF_AJ
TABLE ACCESS BY INDEX ROWID MF_TJ
INDEX UNIQUE SCAN PK_TJ
VIEW VW_NSO_1
SORT UNIQUE
HASH JOIN
TABLE ACCESS FULL MF_CR_LN
TABLE ACCESS FULL MF_CR

-----table not analyzed------------
SELECT STATEMENT Cost=335577
SORT UNIQUE
UNION-ALL
SORT GROUP BY
NESTED LOOPS
HASH JOIN
INDEX FAST FULL SCAN I3_ST_EXP_AUTY_MNTN
NESTED LOOPS
TABLE ACCESS FULL MF_AJ
TABLE ACCESS BY INDEX ROWID MF_TJ
INDEX UNIQUE SCAN PK_TJ
TABLE ACCESS FULL MF_SYS_STGS
SORT GROUP BY
HASH JOIN
TABLE ACCESS FULL MF_SYS_STGS
NESTED LOOPS
HASH JOIN
INDEX FAST FULL SCAN I3_ST_EXP_AUTY_MNTN
HASH JOIN
TABLE ACCESS FULL MF_AJ
TABLE ACCESS FULL MF_TJ
VIEW VW_NSO_1
SORT UNIQUE
HASH JOIN
TABLE ACCESS FULL MF_CR_LN
TABLE ACCESS FULL MF_CR

Reply With Quote
  #2  
Old   
Sybrand Bakker
 
Posts: n/a

Default Re: After table analyzed query runs 8 hours longer - 09-17-2004 , 03:12 PM






On 17 Sep 2004 12:59:02 -0700, pburns13 (AT) hotmail (DOT) com (Patrick Burns)
wrote:

Quote:
All of the other queries run faster
but this one. I have tried creating all kinds of indexes with no
success.
Wchich query? Which indexes? Which Analyze command? Which version of
Oracle?


--
Sybrand Bakker, Senior Oracle DBA


Reply With Quote
  #3  
Old   
Patrick Burns
 
Posts: n/a

Default Re: After table analyzed query runs 8 hours longer - 09-20-2004 , 08:19 AM



Quote:
Wchich query?
We have 5 other queries that pull the similar information but are
structure different.

Quote:
Which indexes?
Indexes on the columns used in the where clause, I have tried using
single indexes ass well as multiple indexes.

Quote:
Which Analyze command?
I have done analyze table mf_aj compute statistics and well as
estimate statistics.

Quote:
Which version of Oracle?
817


Reply With Quote
  #4  
Old   
Daniel Roy
 
Posts: n/a

Default Re: After table analyzed query runs 8 hours longer - 09-20-2004 , 02:34 PM



From what I see, your slow-running query accesses multiple tables, but
you say that you calculated stats for ONE table. Be consistent and
analyze the stats for ALL the tables involved. Please post at least
the query.

Daniel

Reply With Quote
  #5  
Old   
Daniel Morgan
 
Posts: n/a

Default Re: After table analyzed query runs 8 hours longer - 09-20-2004 , 08:32 PM



Daniel Roy wrote:

Quote:
From what I see, your slow-running query accesses multiple tables, but
you say that you calculated stats for ONE table. Be consistent and
analyze the stats for ALL the tables involved. Please post at least
the query.

Daniel
And, in addition, do not use DBMS_UTLITY procedures ... you should be
using DBMS_STATS.
--
Daniel A. Morgan
University of Washington
damorgan@x.washington.edu
(replace 'x' with 'u' to respond)



Reply With Quote
  #6  
Old   
Patrick Burns
 
Posts: n/a

Default Re: After table analyzed query runs 8 hours longer - 09-21-2004 , 09:44 AM



Daniel Morgan <damorgan@x.washington.edu> wrote

Quote:
Daniel Roy wrote:

From what I see, your slow-running query accesses multiple tables, but
you say that you calculated stats for ONE table. Be consistent and
analyze the stats for ALL the tables involved. Please post at least
the query.

Daniel

And, in addition, do not use DBMS_UTLITY procedures ... you should be
using DBMS_STATS.

Sorry for the confusion all of the tables were previously analyzed but
the one that I just did. I will attempt to use DBMS_STATS.

explain plan set statement_id= 'x' for select /*+ CHOOSE */ distinct
substr(ea.alte_post_id,7,3),aj.actg_evnt,tj.dtyp,t j.ref_dtyp_cat,sum(tj.dllr_am)
FROM MF_TJ tj, MF_AJ aj, ST_EXP_AUTY_MNTN ea, MF_SYS_STGS syst
WHERE (ea.actg_cetr_post_id = syst.actg_cetr_post_id) AND
(aj.orgn_typ = 'SH') AND
(tj.uid_lo = aj.tj_uid_lo) AND
(TJ.OPLK > '01-JAN-99') AND
((((aj.actg_evnt = 'SP02') or (aj.actg_evnt = 'SP03') or
(aj.actg_evnt = 'SPN3') or (aj.actg_evnt = 'SP07') or (aj.actg_evnt
= 'SPN7') or (aj.actg_evnt = 'AR04') or (aj.actg_evnt = 'AR05') or
(aj.actg_evnt = 'AR06') or (aj.actg_evnt = 'AR10') or (aj.actg_evnt
= 'AR11') or (aj.actg_evnt ='AR12'))
OR (aj.actg_evnt = 'SP05' AND ((tj.line_typ = 'PP') or
(tj.line_typ = 'PR')))
OR (aj.actg_evnt = 'SPN5' AND ((tj.line_typ = 'PP') or
(tj.line_typ = 'PR')))
OR (aj.actg_evnt = 'SP08' AND ((tj.line_typ = 'PP') or
(tj.line_typ = 'PR')))
OR (aj.actg_evnt = 'SPN8' AND ((tj.line_typ = 'PP') or
(tj.line_typ = 'PR')))) AND
AJ.PATN = substr(EA.PATN_ID,7,4) AND
(aj.fund = substr(EA.FUND_ID,7,instr(ea.fund_id,'&',1,3)-instr(ea.fund_id,'&',1,2)-1)
AND
AJ.BBFY = substr(EA.FUND_ID,instr(ea.fund_id,'&',1,3)+1,inst r(ea.fund_id,'&',1,4)-instr(ea.fund_id,'&',1,3)-1))
AND
aj.orgn = substr(EA.ORGN_ID,instr(ea.orgn_id,'&',1,2)+1,inst r(ea.orgn_id,'&',1,3)-instr(ea.orgn_id,'&',1,2)-1))
GROUP BY substr(ea.alte_post_id,7,3),aj.actg_evnt,tj.dtyp,t j.ref_dtyp_cat
UNION
SELECT /*+ CHOOSE */ substr(ea.alte_post_id,7,3), aj.actg_evnt,'ZZ','
', sum(tj.dllr_am)
FROM MF_TJ tj, MF_AJ aj, ST_EXP_AUTY_MNTN ea, MF_SYS_STGS syst
WHERE (ea.actg_cetr_post_id = syst.actg_cetr_post_id) AND
(aj.orgn_typ = 'SH') AND
(tj.uid_lo = aj.tj_uid_lo) AND
(TJ.OPLK > '01-JAN-99') AND
(aj.actg_evnt = 'AR04' or aj.actg_evnt = 'AR05' or aj.actg_evnt =
'AR06' or
aj.actg_evnt = 'AR10' or aj.actg_evnt = 'AR11' or aj.actg_evnt =
'AR12') AND
(tj.ref_doc_num is null and tj.cat = 'CR') AND
AJ.PATN = substr(EA.PATN_ID,7,4) AND
aj.fund = substr(EA.FUND_ID,7,instr(ea.fund_id,'&',1,3)-instr(ea.fund_id,'&',1,2)-1)
AND
AJ.BBFY = substr(EA.FUND_ID,instr(ea.fund_id,'&',1,3)+1,inst r(ea.fund_id,'&',1,4)-instr(ea.fund_id,'&',1,3)-1)
AND
aj.orgn = substr(EA.ORGN_ID,instr(ea.orgn_id,'&',1,2)+1,inst r(ea.orgn_id,'&',1,3)-instr(ea.orgn_id,'&',1,2)-1)
AND tj.dtyp||tj.doc_num||rtrim(tj.actg_lnum_ch) in
(select substr(cr.dtyp_id,7)||cr.doc_num||rtrim(crln.lnum)
from MF_CR cr, MF_CR_LN crln
where cr.uidy = crln.parn_of_line_id and crln.rord_line_id is not
null)
GROUP BY substr(ea.alte_post_id,7,3), aj.actg_evnt, ' ',' ';


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.