Solved

Improve performance

Posted on 2011-09-28
18
524 Views
Last Modified: 2012-05-12
How to improve performance in the following sentence?

SELECT FUNHVA.FAE_ID ID_DIS,
                F.NIS NIS,
                ('(' || DECODE(FXA.FIC_ID, NULL, 'NA', FXA.FIC_ID) || ')' ||
                EVAMB.EVA_DESCRIPCION) EVENTO,
                TO_CHAR(HVA.HVA_HORA_INICIO, 'dd/MM/yyyy hh24:mi') FEC_INI,
                TO_CHAR(HVA.HVA_HORA_FIN, 'dd/MM/yyyy hh24:mi') FEC_FIN,
                HVA.HVA_HORA_INICIO FECHA,
                A.AMB_NOMBRE AMBIENTE,
                EVAMB.EVA_ID EVENTO_ID
           FROM GESAMBIENTE.FUNCIONARIOXHVA         FUNHVA,
                GESAMBIENTE.HORARIO_EVENTO_AMBIENTE HVA,
                GESAMBIENTE.EVENTO_AMBIENTE         EVAMB,
                GESAMBIENTE.PROGRAMACION_AMBIENTE   PGA,
                GESAMBIENTE.FICHAXAMBIENTE          FXA,
                GESAMBIENTE.PPFXINSTRUCTOR          PPFINST,
                COMUN.FUNCIONARIO                   F,
                GESAMBIENTE.AMBIENTE                A
          WHERE HVA.HVA_ID = FUNHVA.HVA_ID
            AND EVAMB.EVA_ID = HVA.EVA_ID
            AND F.NIS = NVL(PPFINST.NIS_INSTRUCTOR, FUNHVA.NIS_FUN_APOYA)
            AND FUNHVA.PPI_ID = PPFINST.PPI_ID(+)
            AND FUNHVA.FAE_ESTADO <> 2
            AND PGA.PGA_ID(+) = EVAMB.PGA_ID
            AND HVA.HVA_ESTADO = '1'
            AND FXA.FIA_ID(+) = PGA.FIA_ID
            AND A.AMB_ID = EVAMB.AMB_ID
            AND ((PPFINST.NIS_INSTRUCTOR = 2334338 AND FUNHVA.NIS_FUN_APOYA IS NULL) OR
                 (FUNHVA.NIS_FUN_APOYA = 2336400   AND FUNHVA.PPI_ID IS NULL))
            AND TRUNC(HVA.HVA_HORA_FIN) <= SYSDATE
            AND TRUNC(HVA.HVA_HORA_INICIO) >= SYSDATE - 20

Gracias

Jair Duran
explainPlan.jpg
GESAMBIENTE.PPFXINSTRUCTOR.txt
0
Comment
Question by:jairdur
  • 10
  • 6
  • 2
18 Comments
 
LVL 15

Expert Comment

by:Devinder Singh Virdi
Comment Utility
How much time it is taking and how much you want?
0
 
LVL 15

Expert Comment

by:Devinder Singh Virdi
Comment Utility
Also provide full execution plan. The attached plan is not completely view able.
0
 

Author Comment

by:jairdur
Comment Utility
Full Explain Plan explainPlan.txt
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
Comment Utility
That is hard to read.  
Please post the results from sqlplus:

SQL> explain plan for
select ... your select
/

SQL> select * from table(dbms_xplan.display);
0
 

Author Comment

by:jairdur
Comment Utility
SQL> select * from table(dbms_xplan.display);

PLAN_TABLE_OUTPUT
-------------------------------------------------------------------------------

Error: cannot fetch last explain plan from PLAN_TABLE


Plan de Ejecuci¾n
----------------------------------------------------------
ERROR:
ORA-00604: error occurred at recursive SQL level 1
ORA-01157: cannot identify/lock data file 501 - see DBWR trace file
ORA-01110: data file 501: '+DGARC/sofia/tempfile/temp.dbf'


SP2-0612: Error al generar el informe AUTOTRACE EXPLAIN

EstadÝsticas
----------------------------------------------------------
         24  recursive calls
          0  db block gets
        120  consistent gets
          0  physical reads
          0  redo size
        395  bytes sent via SQL*Net to client
        350  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          1  sorts (memory)
          0  sorts (disk)
          1  rows processed

SQL>
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
Comment Utility
>>ORA-01110: data file 501: '+DGARC/sofia/tempfile/temp.dbf'

You might want/need to get that looked at.

>>Error: cannot fetch last explain plan from PLAN_TABLE

Not quite what I was looking for.

Can you try again and see if the TEMP error is still there?
0
 

Author Comment

by:jairdur
Comment Utility
No, no jet.

Sorry
0
 

Author Comment

by:jairdur
Comment Utility
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
Comment Utility
While I try do decipher the plan from an image can you respond to the other Experts question about expectations?  How long does it take now and what are you trying to get?

'make it faster' doesn't help a lot when tuning SQL.


It looks like the outer join above the highlighted line is causing most of the problems.

0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:jairdur
Comment Utility
9.75 seg
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
Comment Utility
Is that the current time or expected time?

I apologize for asking this because of the language differences but is that 9.75 seconds?
0
 

Author Comment

by:jairdur
Comment Utility
Excuse me

Is that the current time 9.57 sec
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
Comment Utility
What are you looking to get this down to?
0
 

Author Comment

by:jairdur
Comment Utility
reduce execution time and avoid the full access table
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
Comment Utility
A full table scan is not always bad.

Like I mentioned before it looks like the outer join is the bad guy here.
0
 

Assisted Solution

by:jairdur
jairdur earned 0 total points
Comment Utility
I just solved with UNION ALL. thanks
0
 

Accepted Solution

by:
jairdur earned 0 total points
Comment Utility

SELECT FUNHVA.FAE_ID ID_DIS, 
       F.NIS NIS, 
       ('(' || DECODE(FXA.FIC_ID, NULL, 'NA', FXA.FIC_ID) || ')' || EVAMB.EVA_DESCRIPCION) EVENTO, 
       TO_CHAR(HVA.HVA_HORA_INICIO, 'dd/MM/yyyy hh24:mi') FEC_INI, 
       TO_CHAR(HVA.HVA_HORA_FIN, 'dd/MM/yyyy hh24:mi') FEC_FIN, 
       HVA.HVA_HORA_INICIO FECHA, 
       A.AMB_NOMBRE AMBIENTE, 
       EVAMB.EVA_ID EVENTO_ID 
  FROM GESAMBIENTE.FUNCIONARIOXHVA FUNHVA, 
       GESAMBIENTE.HORARIO_EVENTO_AMBIENTE HVA, 
       GESAMBIENTE.EVENTO_AMBIENTE EVAMB, 
       GESAMBIENTE.PROGRAMACION_AMBIENTE PGA, 
       GESAMBIENTE.FICHAXAMBIENTE FXA, 
       GESAMBIENTE.PPFXINSTRUCTOR PPFINST, 
       COMUN.FUNCIONARIO F, 
       GESAMBIENTE.AMBIENTE A 
 WHERE HVA.HVA_ID    = FUNHVA.HVA_ID 
   AND EVAMB.EVA_ID  = HVA.EVA_ID 
   AND F.NIS         = NVL(PPFINST.NIS_INSTRUCTOR, FUNHVA.NIS_FUN_APOYA) 
   AND FUNHVA.PPI_ID = PPFINST.PPI_ID (+) 
   AND FUNHVA.FAE_ESTADO <> 2 
   AND PGA.PGA_ID (+) = EVAMB.PGA_ID 
   AND HVA.HVA_ESTADO = '1' 
   AND FXA.FIA_ID (+) = PGA.FIA_ID 
   AND A.AMB_ID       = EVAMB.AMB_ID 
   AND (PPFINST.NIS_INSTRUCTOR = 10279121 AND FUNHVA.NIS_FUN_APOYA IS NULL)
   AND TRUNC(HVA.HVA_HORA_FIN) <= to_Date('01092011','ddmmyyyy') 
   AND TRUNC(HVA.HVA_HORA_INICIO) >= to_Date('01012011','ddmmyyyy')
union all 
SELECT FUNHVA.FAE_ID ID_DIS, 
       F.NIS NIS, 
       ('(' || DECODE(FXA.FIC_ID, NULL, 'NA', FXA.FIC_ID) || ')' || EVAMB.EVA_DESCRIPCION) EVENTO, 
       TO_CHAR(HVA.HVA_HORA_INICIO, 'dd/MM/yyyy hh24:mi') FEC_INI, 
       TO_CHAR(HVA.HVA_HORA_FIN, 'dd/MM/yyyy hh24:mi') FEC_FIN, 
       HVA.HVA_HORA_INICIO FECHA, 
       A.AMB_NOMBRE AMBIENTE, 
       EVAMB.EVA_ID EVENTO_ID 
  FROM GESAMBIENTE.FUNCIONARIOXHVA FUNHVA, 
       GESAMBIENTE.HORARIO_EVENTO_AMBIENTE HVA, 
       GESAMBIENTE.EVENTO_AMBIENTE EVAMB, 
       GESAMBIENTE.PROGRAMACION_AMBIENTE PGA, 
       GESAMBIENTE.FICHAXAMBIENTE FXA, 
       GESAMBIENTE.PPFXINSTRUCTOR PPFINST, 
       COMUN.FUNCIONARIO F, 
       GESAMBIENTE.AMBIENTE A 
 WHERE HVA.HVA_ID = FUNHVA.HVA_ID 
   AND EVAMB.EVA_ID = HVA.EVA_ID 
   AND F.NIS = NVL(PPFINST.NIS_INSTRUCTOR, FUNHVA.NIS_FUN_APOYA) 
   AND FUNHVA.PPI_ID = PPFINST.PPI_ID (+) 
   AND FUNHVA.FAE_ESTADO <> 2 
   AND PGA.PGA_ID (+) = EVAMB.PGA_ID 
   AND HVA.HVA_ESTADO = '1' 
   AND FXA.FIA_ID (+) = PGA.FIA_ID 
   AND A.AMB_ID = EVAMB.AMB_ID 
   AND (FUNHVA.NIS_FUN_APOYA = 7958573 AND FUNHVA.PPI_ID IS NULL)
   AND TRUNC(HVA.HVA_HORA_FIN) <= to_Date('01092011','ddmmyyyy') 
   AND TRUNC(HVA.HVA_HORA_INICIO) >= to_Date('01012011','ddmmyyyy')

Open in new window

0
 

Author Closing Comment

by:jairdur
Comment Utility
Apply UNION ALL
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now