Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Queries on MSEG are slow

Former Member
0 Kudos

Hallo

Has anyone any tips to speed up MSEG operations? I need history from this table from 30 days back. I need only a few fields from MSEG but any select on this table is 50min time long ;-( Any guidance how to create views (if this will speed up my queries).

Thank you for any help.

Radek

7 REPLIES 7

Former Member
0 Kudos

Hi,

MSEG generally is VERY BIG table therefore you have to count that queries would be take a long time.

to improve it --

1) check if your select use any of indexes or primary key of MSEG

2) select as less as possible

3) check database statistic

4) post the select statement you do, might be we found something

BR, Artem

remember points

Message was edited by:

Artem Ruzak

Former Member
0 Kudos

Hi,

1. give condition in where clause which is primary keys in table (mblnr mjhr, posnr only) or chk secondary index and give condition in that field only.

2. donot give conditon on non key fields.!!!

3. or use for all entires command

Jogdand M B

Former Member
0 Kudos

Hi Radoslaw,

Reading MSEG can be quick - see for example transaction MB51 which uses the supplied index on plant and material. What kind of data selection are you making?

If the selection is based on fields that are not key fields and not in an index, then the selection will be slow.

I have also seen it where people are reading MSEG when there are better tables to read e.g. table EKBE if you want to get details of movements against a purchase order.

It would not make sense to set up a view, you might have to create a new index on MSEG.

Former Member
0 Kudos

SELECT on MKPF first using the posting date (BUDAT). There is an index on this field. Use the document number you get from MKPF to select against MSEG. This will definitely speed up the program.

Rob

Former Member
0 Kudos

<b>Hello all.

I would like to share yet another SQL performance tip, its relevant for anyone developing in SAP R3/ECC. I found some very useful notes on customer developments in MM/SD/PP/PM. They describe common sql errors made by developers when they develop programs that select from the following tables:

MSEG, LTAP, EBAN, RSEG, AFRU, AFKO, AUFK, CAUFV, RESB, VBAK, VBAP, VMVA, LIKP, LIPS, VBRK, VBRP, VBFA

Here are the note numbers : 191492,187906,185530.

They are very hard to find by regular means. (like searching for "mseg sql performance".) In general they describe the use of "INDEX TABLES", these are tables that act as indexes to the sap tables. They are maintained by sap (you may need to do some customizing for this to actually work).

These notes may save you time/trouble/performance problems/creating additional indexes. In other words, if your installation has customer developments in these areas (MM,SD,PP,PM) these notes are MUST READS.</b>

reward points if it is usefull ....

Girish

0 Kudos

Excellent information Girish. I wasn't aware of these notes.

I couldn't find anything similar for FI.

Rob

0 Kudos

Another way to speed up queries against MSEG and other big ones might be to keep your own data excerpts for those purposes. To do so, you can implement the BADI MB_DOCUMENT_UPDATE where you check already then the document against your selection criteria and if it applies, write it to your own Z-Table. However, this makes only sense, if the amount of records that apply is comparably small, otherwise you might things even worse.

Depending on what you want to achieve, you might also consider to implement a logistics information system (LIS)

Hope that helps

Frank