Solved

Improve performance

Posted on 2011-09-28
18
531 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 77

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 77

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 77

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 77

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 77

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 77

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
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…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

738 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