‎2009 Oct 10 10:13 AM
Hi..
The below select query is causing performance issue in production , it is taking much time.
Please suggest how to optimize it .
SELECT belnr bukrs gjahr awkey blart FROM bkpf
INTO TABLE t_bkpf
WHERE bukrs IN s_bukrs AND
gjahr IN r_year.
Regards
chetan
Moderator message - Please see before posting - post locked
Edited by: Rob Burbank on Oct 13, 2009 10:49 AM
‎2009 Oct 10 11:45 AM
Hi Chetan,
I suggest the following to optimize your performance.
- Change the order of the fields (belnr bukrs gjahr awkey blart), so that they're in the same order than showned in SE11 table data definition (you may need to change the order in t_bkpf definiton also).
- Add the client in your select statement.
Something like this:
SELECT bukrs belnr gjahr blart awkey FROM bkpf CLIENT SPECIFIED
INTO TABLE t_bkpf
WHERE mandt = sy-mandt
AND bukrs IN s_bukrs
AND gjahr IN r_year.
Your statement it's very simple. I don't think that there is much more to do.
Hope that helps.
Kind regards.
Edited by: Bruno Garcia on Oct 10, 2009 10:48 AM
‎2009 Oct 10 5:42 PM
Hi Chetan,
I think your code is perfect..as Bruno replied there is nothing much to change because it will use primary index of BKPF table...
Only one thing you need to check is that make sure that S_bukrs and R_year have values..
Hope this reply helps you..:)
Regards
Basavaraj
‎2009 Oct 12 6:44 AM
Hi Chetan,
Try to give maximum possible key fieds in where condition.If possible give BELNR(Accounting document number) also in where condition.Otherwise u can go with Bruno statement.
Thanks & Regards,
Pydi Reddy.
‎2009 Oct 12 7:53 AM
> - Add the client in your select statement.
Did you ever hear about the automatic client addition? This recommendation is nonsense! and should not be done!
‎2009 Oct 12 7:56 AM
the problem is related to the select-options!!!
> WHERE bukrs IN s_bukrs AND
> gjahr IN r_year.
Be aware that these are dynamic conditions, only at runtime they aree filled, and they can be empty (non-selective) or
very limiting. So you must check the actual content if you want to figure out the cause of your problem.
Siegfried
‎2009 Oct 13 3:17 PM
Hi chetan teli,
Try this:
SELECT belnr bukrs gjahr awkey blart
FROM bkpf
INTO TABLE t_bkpf
WHERE bukrs IN s_bukrs
AND belnr GT 0
AND gjahr IN r_year.
Add belnr in the Where condition to use the full primary key.
Regards,
José
‎2009 Oct 13 3:47 PM
> Hi chetan teli,
>
> Try this:
>
> SELECT belnr bukrs gjahr awkey blart
> FROM bkpf
> INTO TABLE t_bkpf
> WHERE bukrs IN s_bukrs
> AND belnr GT 0
> AND gjahr IN r_year.
>
> Add belnr in the Where condition to use the full primary key.
>
> Regards,
>
> José
Doing this is not going to make a lot of difference to the amount of data the query will have to search through if, like us, you have a very small number of BUKRS values.