Mailing List
Home
Forum Home
Oracle List - by freelists.org
Oracle on SUSE Linux - Runing Oracle on SUSE Linux
Oracle database error code ...
www.freelists.org
Subjects
ORA 12540: TNS:internal limit restriction exceeded
ORA 12838 please : Is possible to append two times to the same table befo
ORA 12838 please : Is possible to append two times to the same table before
ora 04031
ora 12500 on windows
ORA 32004: obsolete and/or deprecated parameter(s) specified
ORA 01925: maximum of 30 enabled roles exceeded
ORA 01925: maximum of 30 enabled roles exceeded
ora 12500 on windows
ORA 01650, one idea
ORA 01650
ORA 4030
ORA 12838 please : Is possible to append two times to thesametable before do
ORA 12838 please : Is possible to append two times to thesame table before d
ORA 01536
ORA 03113 end of file on communication channel
ORA 32004: obsolete and/or deprecated parameter(s) specified
ORA 00600:
ORA 00020: maximum number of processes (%s) exceeded
ORA 01925: maximum of 30 enabled roles exceeded
ORA 3113 while creating a cluster database 9201 RAC on Linux with OCFS
ora 12500 on windows
ora 12500 on windows
ora 12500 on windows
ORA 01650, one idea
ora 12500 on windows
ora 12500 on windows
ora 12500 on windows
ORA 2000 Error Using DBMS STATS GATHER SCHEMA STATS
ORA 01650, one idea
ORA 01650, one idea
ORA 01650, one idea
ORA 01650
ORA 01650
Subject: ora 01031
ORA 4030
ORA 4030
ORA 06502: PL/SQL: numeric or value error: Bulk Bind: Truncated Bind
Subject: Re: ORA 01722 invalid number
 
Subject: Re: Query Tuning Help

Subject: Re: Query Tuning Help

2007-11-01       - By A Ebadi

 Back
Thanks to everyone who replied.  The version below from Finn (adding hash hint)
ran in 16 minutes!
 

Finn Jorgensen <finn.oracledba@(protected)> wrote:
   The biggest problem for this query is that the IN results in a FILTER
operation, which is very slow, and I'm guessing the inner "MINUS" query returns
a lot of rows.
 
 I'm guessing there's no index on "guid" in call_detail?
 
 Try this version (it's hard tuning queries without access to the database so
a little testing can be done) :
 
 SELECT /*+ parallel(a,10) use_hash(a b) */
        billing_act_nbr, final_tg_nbr, COUNT(*), SUM (call_duration_value),
        SUM (rated_cost_amt)
   FROM cdrw.call_detail a,
 (            SELECT
                  guid
             FROM cdrw.call_detail c
            WHERE orig_dt >= TO_DATE ('20071016000000', 'yyyymmddhh24miss')
              AND orig_dt < TO_DATE ('20071016010000', 'yyyymmddhh24miss')
                       AND (record_typ='STOP' OR call_duration_value>0)
           MINUS
           SELECT
                  guid
             FROM cdrw.call_detail_cost_vero d
            WHERE orig_dt >= TO_DATE ('20071016000000', 'yyyymmddhh24miss')
              AND orig_dt < TO_DATE ('20071016010000', 'yyyymmddhh24miss')) b
   WHERE orig_dt >= TO_DATE ('20071016000000', 'yyyymmddhh24miss')
              AND orig_dt < TO_DATE ('20071016010000', 'yyyymmddhh24miss')
                       AND (record_typ='STOP' OR call_duration_value>0)
    AND a.guid = b.guid
 GROUP BY billing_act_nbr, final_tg_nbr;
 

 Finn

 On 10/31/07, A Ebadi <ebadi01@(protected)> wrote:     We've been trying to tune
this query below, but to no avail.  The table call_detail below is a very large
hourly partitioned table with each partition being about 2-4GB!  The other
table (call_detail_cost_vero) is relatively small.  
 
 The two inner selects with minus runs fine alone in about 6-8 minutes, but
the entire query doesn't finish even after running it for many hours!  We've
tried running it in parallel/no parallel and hasn't helped.  Any
recommendations would be appreciated.  The explain plan is at the bottom of
this e-mail also.
 
 Thanks,
 Abdul
 
 Environment: Sun Solaris, Oracle 10.2.0.3.0 on RAC (4 node)
 
 SELECT /*+ parallel(a,10) */
        billing_act_nbr, final_tg_nbr, COUNT(*), SUM (call_duration_value),
        SUM (rated_cost_amt)
   FROM cdrw.call_detail a
            WHERE orig_dt >= TO_DATE ('20071016000000', 'yyyymmddhh24miss')
              AND orig_dt < TO_DATE ('20071016010000', 'yyyymmddhh24miss')
                       AND (record_typ='STOP' OR call_duration_value>0)
    AND guid IN (
           SELECT
                  guid
             FROM cdrw.call_detail c
            WHERE orig_dt >= TO_DATE ('20071016000000', 'yyyymmddhh24miss')
              AND orig_dt < TO_DATE ('20071016010000', 'yyyymmddhh24miss')
                       AND (record_typ='STOP' OR call_duration_value>0)
           MINUS
           SELECT
                  guid
             FROM cdrw.call_detail_cost_vero d
            WHERE orig_dt >= TO_DATE ('20071016000000', 'yyyymmddhh24miss')
              AND orig_dt < TO_DATE ('20071016010000', 'yyyymmddhh24miss'))
GROUP BY billing_act_nbr, final_tg_nbr;
 
 
 EXPLAIN PLAN
 QUERY_PLAN
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
-- ---- ---- ---- ---- ---- ---- ---- ---
SELECT STATEMENT   Cost = 32
 2.1 HASH GROUP BY
   3.1 FILTER
     4.1 PX COORDINATOR
       5.1 PX SEND QC (RANDOM) ":TQ10000"
         6.1 PX BLOCK ITERATOR
           7.1 TABLE ACCESS FULL "CALL_DETAIL" TABLE
     4.2 MINUS
       5.1 SORT UNIQUE NOSORT
         6.1 PARTITION RANGE SINGLE
           7.1 TABLE ACCESS BY LOCAL INDEX ROWID "CALL_DETAIL" TABLE
 QUERY_PLAN
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
-- ---- ---- ---- ---- ---- ---- ---- ---
             8.1 INDEX RANGE SCAN "CALL_DETAIL_UK" INDEX (UNIQUE)
       5.2 SORT UNIQUE NOSORT
         6.1 PARTITION RANGE SINGLE
           7.1 INDEX RANGE SCAN "CALL_DETAIL_COST_VERO_PK" INDEX (UNIQUE)

 
 __ ____ ____ ____ ____ ____ ____ ____ ____ ____ __
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com




__ ____ ____ ____ ____ ____ ____ ____ ____ ____ __
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
<div>Thanks to everyone who replied.&nbsp; The version below from Finn (adding
hash hint) ran in 16 minutes!</div>  <div><BR><BR><B><I>Finn Jorgensen &lt;finn
.oracledba@(protected)&gt;</I></B> wrote:</div>  <BLOCKQUOTE class=replbq style=
"PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">  <DIV>The
biggest problem for this query is that the IN results in a FILTER operation,
which is very slow, and I'm guessing the inner "MINUS" query returns a lot of
rows.</DIV>  <DIV>&nbsp;</DIV>  <DIV>I'm guessing there's no index on "guid" in
call_detail?</DIV>  <DIV>&nbsp;</DIV>  <DIV>Try this version (it's hard tuning
queries without access to the database so a little testing can be done) :</DIV>
 <DIV>&nbsp;</DIV>  <DIV>SELECT /*+ parallel(a,10) use_hash(a b) */<BR>&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; billing_act_nbr, final_tg_nbr, COUNT(
*), SUM (call_duration_value),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp; SUM
(rated_cost_amt)<BR>&nbsp;&nbsp;&nbsp; FROM cdrw.call_detail a,</DIV>  <DIV>(
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SELECT<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; guid<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FROM cdrw.call_detail c<BR>&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WHERE orig_dt &gt;=
TO_DATE ('20071016000000', 'yyyymmddhh24miss')<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AND orig_dt &lt; TO_DATE
('20071016010000', 'yyyymmddhh24miss') <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp; AND (record_typ='STOP' OR call_duration_value&gt;0)<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
MINUS<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
SELECT<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; guid<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FROM cdrw.call_detail_cost
_vero d<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp; WHERE orig_dt &gt;= TO_DATE ('20071016000000', 'yyyymmddhh24miss') <BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp; AND orig_dt &lt; TO_DATE ('20071016010000', 'yyyymmddhh24miss')) b<BR>
&nbsp;&nbsp;&nbsp; WHERE orig_dt &gt;= TO_DATE ('20071016000000',
'yyyymmddhh24miss')<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AND orig_dt &lt; TO_DATE ('20071016010000',
'yyyymmddhh24miss')
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AND (record
_typ='STOP' OR call_duration_value&gt;0)<BR>&nbsp;&nbsp;&nbsp;&nbsp; AND a.guid
= b.guid</DIV>  <DIV>GROUP BY billing_act_nbr, final_tg_nbr;</DIV>  <DIV><BR>
&nbsp;</DIV>  <DIV>Finn<BR>&nbsp;</DIV>  <DIV><SPAN class=gmail_quote>On 10/31
/07, <B class=gmail_sendername>A Ebadi</B> &lt;<A href="mailto:ebadi01@(protected)
">ebadi01@(protected)</A>&gt; wrote:</SPAN>   <BLOCKQUOTE class=gmail_quote style=
"PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">  
<DIV>We've&nbsp;been trying to tune this query below, but to no avail.&nbsp; The
table call_detail below is a very large hourly partitioned table with each
partition being about 2-4GB!&nbsp; The other table (call_detail_cost_vero) is
relatively small.&nbsp; </DIV>  <DIV>&nbsp;</DIV>  <DIV>The two inner selects
with minus runs fine alone in about 6-8 minutes,
but the entire query doesn't finish even after running it for many hours!&nbsp
; We've tried running it in parallel/no parallel&nbsp;and hasn't helped.&nbsp;
Any recommendations would be appreciated.&nbsp; The explain plan is at the
bottom of this e-mail also. </DIV>  <DIV>&nbsp;</DIV>  <DIV>Thanks,</DIV>  <DIV
>Abdul</DIV>  <DIV>&nbsp;</DIV>  <DIV>Environment: Sun Solaris, Oracle 10.2.0.3
.0 on RAC (4 node)</DIV>  <DIV>&nbsp;</DIV>  <DIV>SELECT /*+ parallel(a,10) */
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; billing_act_nbr, final_tg
_nbr, COUNT(*), SUM (call_duration_value),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; SUM (rated_cost_amt)<BR>&nbsp;&nbsp;&nbsp; FROM cdrw.call
_detail a<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp; WHERE orig_dt &gt;= TO_DATE ('20071016000000', 'yyyymmddhh24miss') <BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp; AND orig_dt &lt; TO_DATE ('20071016010000',
'yyyymmddhh24miss')<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp; AND (record_typ='STOP' OR call_duration_value&gt;0)<BR>&nbsp;&nbsp;&nbsp;
&nbsp; AND guid IN (<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp; SELECT <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; guid<BR>&nbsp;&nbsp;&nbsp
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FROM cdrw.call
_detail c<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp; WHERE orig_dt &gt;= TO_DATE ('20071016000000', 'yyyymmddhh24miss')<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp; AND orig_dt &lt; TO_DATE ('20071016010000', 'yyyymmddhh24miss')
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AND (record
_typ='STOP' OR call_duration_value&gt;0)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MINUS<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SELECT<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; guid<BR
>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
FROM cdrw.call_detail_cost_vero d<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WHERE orig_dt &gt;= TO_DATE ('20071016000000',
'yyyymmddhh24miss') <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AND orig_dt &lt; TO_DATE ('20071016010000',
'yyyymmddhh24miss'))<BR>GROUP BY billing_act_nbr, final_tg_nbr;</DIV>  <DIV>
&nbsp;</DIV>  <DIV>&nbsp;</DIV>  <DIV>EXPLAIN
PLAN</DIV>  <DIV>QUERY_PLAN<BR>-- ---- ---- ---- ---- ---- ---- ---- ---- ----
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -----<BR>
&nbsp;SELECT STATEMENT&nbsp;&nbsp; Cost = 32<BR>&nbsp; 2.1 HASH GROUP BY<BR>
&nbsp;&nbsp;&nbsp; 3.1 FILTER<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4.1 PX
COORDINATOR<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5.1 PX SEND QC
(RANDOM) ":TQ10000"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6
.1 PX BLOCK ITERATOR<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp; 7.1 TABLE ACCESS FULL "CALL_DETAIL" TABLE<BR>&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp; 4.2 MINUS<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5.1 SORT
UNIQUE NOSORT <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6.1
PARTITION RANGE SINGLE<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
;&nbsp;&nbsp; 7.1 TABLE ACCESS BY LOCAL INDEX ROWID "CALL_DETAIL" TABLE</DIV>
<DIV>QUERY_PLAN<BR>-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---<BR>&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8.1 INDEX
RANGE SCAN "CALL_DETAIL_UK" INDEX (UNIQUE)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp; 5.2 SORT UNIQUE NOSORT<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
;&nbsp;&nbsp; 6.1 PARTITION RANGE SINGLE<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7.1 INDEX RANGE SCAN "CALL_DETAIL_COST_VERO_PK"
INDEX (UNIQUE)<BR>&nbsp;</DIV><SPAN class=ad>  <DIV>&nbsp;</DIV>  <div>__ _____
__ ____ ____ ____ ____ ____ ____ ____ ____<BR>Do You Yahoo!?<BR>Tired of spam?
Yahoo! Mail has the best spam protection around <BR><A onclick="return top.js
.OpenExtLink(window,event,this)" href="http://mail.yahoo.com/" target=_blank
>http://mail.yahoo.com</A>
</div></SPAN></BLOCKQUOTE></DIV><BR></BLOCKQUOTE><BR><p>&#32;__ ____ ____ ____
__ ____ ____ ____ ____ ____ _____<br>Do You Yahoo!?<br>Tired of spam?  Yahoo!
Mail has the best spam protection around <br>http://mail.yahoo.com