Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Improve performance

Posted on 2011-09-28
18
Medium Priority
?
536 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

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 copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

670 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