Solved

Improve performance

Posted on 2011-09-28
18
526 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
ID: 36718302
How much time it is taking and how much you want?
0
 
LVL 15

Expert Comment

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

Author Comment

by:jairdur
ID: 36718352
Full Explain Plan explainPlan.txt
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.

 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 36718371
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
ID: 36718443
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)
ID: 36718476
>>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
ID: 36718562
No, no jet.

Sorry
0
 

Author Comment

by:jairdur
ID: 36719481
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 36719536
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
 

Author Comment

by:jairdur
ID: 36719679
9.75 seg
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 36719700
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
ID: 36719764
Excuse me

Is that the current time 9.57 sec
0
 
LVL 76

Expert Comment

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

Author Comment

by:jairdur
ID: 36720066
reduce execution time and avoid the full access table
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 36720363
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
ID: 36720538
I just solved with UNION ALL. thanks
0
 

Accepted Solution

by:
jairdur earned 0 total points
ID: 36720545

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
ID: 36972722
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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

770 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