Posted: Tue Feb 12, 2008 1:55 pm Post subject: Селект KEKO и CKIS
Коллеги, помогите оптимизировать запрос. Вываливается по таймауту. Количество записей по материалу ~ 1500.
В системе есть индекс KEKO~Z01
по полям KALNR MATNR
Code:
* Selects the data from KEKO & CKIS
SELECT a~kadky " Costing date (key)
a~matnr " Product
a~werks " Plant
a~kadat " Valid date from
a~bidat " Valid date to
a~losau " Lot size
b~posnr " Position no.
b~typps " Item category
b~matnr " Component
b~peinh " Price unit of prices
b~wrtfw_kpf " Value trans. curr.
b~fwaer_kpf " Trans. curr.
b~tpreis " Price trans. curr.
INTO TABLE it_kekis
FROM keko AS a INNER JOIN ckis AS b
ON a~bzobj = b~bzobj
AND a~kalnr = b~kalnr
AND a~kalka = b~kalka
AND a~kadky = b~kadky
AND a~tvers = b~tvers
AND a~bwvar = b~bwvar
AND a~kkzma = b~kkzma
FOR ALL ENTRIES IN it_material
WHERE a~matnr EQ it_material-matnr
AND a~kalnr EQ it_material-kalnr
AND a~kalka EQ '01'
AND a~werks EQ it_material-werks
AND a~feh_sta EQ i_co_status.
Age: 175 Joined: 04 Oct 2007 Posts: 1218 Location: Санкт-Петербург
Posted: Tue Feb 12, 2008 3:37 pm Post subject:
Ваша проблема, что в связи полей для Join не используется поле CKIS-LEDNR- второе в ключе, поэтому неэффективно используется первичный индекс.
У меня в системе значение этого поля всегда '00'.
Для своей системы я бы написал:
Code:
FROM keko AS a INNER JOIN ckis AS b
ON b~LEDNR = '00'
AND a~bzobj = b~bzobj
Если у вас поле LEDNR содержит разные значения, видимо придется создавать вторичный индекс для ckis~z01
по полям:
mandt bzobj kalnr kalka kadky tvers bwvar kkzma
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.