03-17-2008 7:48 PM
Hi Guys,
I have a query on table VBAP which fetches data based on date-time stamp and few other fields. Date-tme fields are always filled. If no plant is additionally entered, query runs for about 20 minutes. However, when user enters a plant, query runs for ever (Last run took about 16 hours). I tried tweaking the "where clause" a bit with no sign of improved performance. I really don't understand why should plant mess with the index.
Your replies are appreciated.
Thanks
Yogi
SELECT bvbeln bposnr buepos bmatnr bwerks bmeins b~objnr
berdat cwebaz cplifz efabkl e~pipatg
INTO TABLE pt_order
FROM vbak AS a
INNER JOIN vbap AS b
ON avbeln = bvbeln
INNER JOIN marc AS c
ON bmatnr = cmatnr AND
bwerks = cwerks
INNER JOIN vbuk AS d
ON avbeln = dvbeln
INNER JOIN tvst AS e
ON bvstel = evstel
WHERE a~vkorg IN s_vkorg
AND a~auart IN s_auart
AND ( ( ( berdat LT s_erdat-high ) OR ( berdat EQ s_erdat-high
AND b~erzet LE p_totim ) )
AND ( ( berdat GT s_erdat-low ) OR ( berdat EQ s_erdat-low
AND b~erzet GE p_frtim ) ) )
AND b~werks IN s_werks
AND b~abgru IN s_abgru
AND c~mtvfp IN s_mtvfp
AND d~cmgst IN s_cmgst.
03-17-2008 8:12 PM
It would help if you could list the indexes and their fields for table VBAP in your system.
03-17-2008 8:51 PM
List of indexes on VBAP
index on MANDT OBJNR
index on MANDT VPMAT & VPWRK
Index on MATNR, ERDAT