Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Tuning SQL | Partition Table | MJC

764492Apr 20 2010 — edited Apr 21 2010
All good hearted people -

Problem :- This SQL runs forever and returns nothing when STATS are stale. If I collect the table level stats (dbms_stats) on these partitioned table it runs again as normal (< 2 minutes).
I see Merge Join cartesian in the explain plan when it runs bad. After the stats done, this MJC disappeared from the plan and things back to normal.

Also, If convert one of those partition into a regular table(amms partition 2010-03-16 ) and join to the other partition table's (cust ) partition this works fine.

Note : After every load we run partition level stats on these tables (not table level stats).

My question is why am I getting MJC? How to solve this issue?


<code>
select aln.acct_no as acct_no, aln.as_of_dt, max(acm.appno) as appno, count( * )
from amr.amms aln, acr.cust acm <================= both tables are range partitioned by date
where acm.acctno = aln.acct_no
and acm.acctno > 0
and acm.as_of_dt = date '2010-03-16' <============ partition key on cust table < 2M rows
and aln.as_of_dt = date '2010-03-12' < ============= partition key on amms table < 2M rows
group by aln.acct_no, aln.as_of_dt
having count( * ) = 1
</code>

Env: Oracle 10g | 10.2.0.4 | ASM | 2 node RAC | Linux x86 | Archivelog | Partition | Optimizer Choose |
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 19 2010
Added on Apr 20 2010
2 comments
1,100 views