SQL - Optimizacion de consulta

   
Vista:

Optimizacion de consulta

Publicado por Jose (3 intervenciones) el 11/11/2015 16:16:58
Buenas tardes,

¿A alquien se le ocurre como optimizar esta consulta?
Estoy trabajando con Informix.

Gracias

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
create view xpromel(me010,me020,me030,me040,me050,me060,me070,me080,me090,
me100,me110,me120,me130,me140,me150,me160,me170,me180,me190,me200)
as
select
ar030,ar000,ar020,
(select ai030 from fproaim where ai019=ar999 and ai020=ar000 and
 ai010=1 and ai025=1),
(select ai030 from fproaim where ai019=ar999 and ai020=ar000 and
ai010=1 and ai025=2),
ar116,ar117,ar118,ar140,
(select ae010 from fproart_edm where ae999=ar999 and ae000=ar000),
(select ae060 from fproart_edm where ae999=ar999 and ae000=ar000),
(select ae290 from fproart_edm where ae999=ar999 and ae000=ar000),
(select ae320 from fproart_edm where ae999=ar999 and ae000=ar000),
(select ae330 from fproart_edm where ae999=ar999 and ae000=ar000),
(select ae350 from fproart_edm where ae999=ar999 and ae000=ar000),
(select ae360 from fproart_edm where ae999=ar999 and ae000=ar000),
ar190,
(select fa010 from fprofam where fa000=ar190),
ar200,
(select sf020 from fprosfa where sf000=ar190 and sf010=ar200)
from fproart
where ar630='A' and  ar030='M' or ar030='N';
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

Optimizacion de consulta

Publicado por DAVID (23 intervenciones) el 06/08/2016 09:29:12
Para empezar yo quitaria esto:
1
2
3
4
5
6
7
8
select ae010 from fproart_edm where ae999=ar999 and ae000=ar000),
(select ae060 from fproart_edm where ae999=ar999 and ae000=ar000),
(select ae290 from fproart_edm where ae999=ar999 and ae000=ar000),
(select ae320 from fproart_edm where ae999=ar999 and ae000=ar000),
(select ae330 from fproart_edm where ae999=ar999 and ae000=ar000),
(select ae350 from fproart_edm where ae999=ar999 and ae000=ar000),
(select ae360 from fproart_edm where ae999=ar999 and ae000=ar000),
ar190,
Y pondria esto:
1
select ae010 ,ae060 ,ae290 ,ae320,ae330,ae350, ae360 from fproart_edm where ae999=ar999 and ae000=ar000),

Un saludo,
David
diseño web madrid
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar