Ver Mensaje Individual
  #1  
Viejo 16/12/09, 10:06:46
Avatar de Jonathan Barrio Rodriguez
Jonathan Barrio Rodriguez Jonathan Barrio Rodriguez is offline
Senior Member
 
Fecha de Ingreso: oct 2007
Localización: MADRID
Mensajes: 199
Optimización Select (INDICE se coge con operador IN )

Buenas...

Exposicion de la circunstancia:
Me informan que una select hace una lectura secuencial, está en un job que lleva 2 días ahí atascado (por supuesto, el número de registros es elevadísimo) y que hay un indice que no se está aprobechando.


Consultas:
¿ Utiliza la select el indice si el operador de comparación es un "IN" ?
¿ Existe alguna herramienta en R/3 qué me indique si ese indice se usará o no?
¿ Tendrá alguna incidencia el hecho que la igualdad del FOR ALL ENTRIES IN no esté en la primera condición del WHERE ?

Código (Las dos alternativas compilan):
*DECLARACION DE DATOS:

data: r_fecha type range of sy-datum,
wa_fecha like line of r_fecha,
w_interr_ele_aux type standard table of zcali_interr_ele,
w_interr_ele type standard table of zcali_interr_ele.

FREE: r_fecha, wa_fecha.

CONCATENATE:
SY-DATUM(4) '0101' INTO wa_fecha-low,
SY-DATUM(4) '1231' INTO wa_fecha-high.
Move: 'I' TO wa_fecha-sign,
'BT' TO wa_fecha-option.
APPEND wa_fecha to r_fecha.

1ª sin indice.
SELECT
MANDT
ID_INCIDENCIA
VSTELLE
ANLAGE
FECHA_MODIF
HORA_MODIF
AB
ATIME
BUKRS
GPART
VERTRAG
DURACION
CAUSA
CLASIFICACION
ZONA
STATUS
ID_USUARIO
FROM
zcali_interr_ele APPENDING TABLE w_interr_ele
FOR ALL ENTRIES IN w_interr_ele_aux
WHERE vstelle = w_interr_ele_aux-vstelle
AND ab IN r_fecha
AND causa = '0200'
*and clasificacion in ('0204', '0205', '0201')
AND status = 'APCA'.

2ª respetando el indice.
SELECT
MANDT
ID_INCIDENCIA
VSTELLE
ANLAGE
FECHA_MODIF
HORA_MODIF
AB
ATIME
BUKRS
GPART
VERTRAG
DURACION
CAUSA
CLASIFICACION
ZONA
STATUS
ID_USUARIO
FROM
zcali_interr_ele APPENDING TABLE w_interr_ele
FOR ALL ENTRIES IN w_interr_ele_aux
WHERE ab IN r_fecha
AND causa = '0200'
*and clasificacion in ('0204', '0205', '0201')
AND status = 'APCA'
AND vstelle = w_interr_ele_aux-vstelle.



Saludos a todos y
como siempre, muchas gracias a todos.
__________________
Barrio Rodriguez, Jonathan.
_____________________________________
"No sigas a quien haya encontrado la verdad sino a quien la busque"

Úlima edición por Jonathan Barrio Rodriguez fecha: 16/12/09 a las 10:12:54.
Responder Con Cita