Skip to Content
0
Former Member
Nov 06, 2007 at 04:47 PM

Improve performance of a SQL request

14 Views

Hi.

I have a sql request with multiple joins in it and when i launch my program i have some performance problems.

I think it's because of the multiple Joins.

How can i improve it ?

Do i need to split it in different smaller requests ?

Thanks for your help and tips.

    SELECT e~ebeln
           e~ebelp
           e~werks
           e~matkl
           e~mtart
           k~lifnr
           k~bstyp
           k~ekgrp
           k~bsart
           k~zzreldt
           t~slfdt
           b~budat
           e~banfn
           e~bnfpo
    FROM ekpo AS e JOIN ekko AS k ON e~ebeln = k~ebeln
                   JOIN eket AS t ON e~ebeln = t~ebeln
                                  AND e~ebelp = t~ebelp
                   JOIN ekbe AS b ON e~ebeln = b~ebeln
                                  AND e~ebelp = b~ebelp
                   JOIN mseg AS m ON e~ebeln = m~ebeln
                                  AND e~ebelp = m~ebelp
    INTO CORRESPONDING FIELDS OF TABLE t_commande
    WHERE k~bstyp IN so_bstyp
    AND   k~lifnr IN so_lifnr
    AND   e~werks IN so_werks
    AND   e~matkl IN so_matkl
    AND   e~mtart IN so_mtart
    AND   k~ekgrp IN so_ekgrp
    AND   k~bsart IN so_bsart
    AND   b~budat IN so_date
    AND   t~etenr EQ '1'
* Ajout des restriction sur code mouvement et stock bloqué
    AND   m~bwart EQ '101'
    AND   m~insmk EQ '3'
* On ne prend que le commandes ayant une référence à une DA
    AND   e~banfn NE ''.