fetching the data from the cluster table
is there any special care to be taken while fetching
the data from the cluster table....
for example i want to fetch the data from the
BSEG table... generally data retrieval from these tables
are very slow... is there any method to improve the performance.....
BSEG table is a cluster table with a key of 4 fields - BUKRS, BELNR, GJAHR and BUZEI. Only the first three are key fields on the underlying cluster table. There are no secondary indexes to this table. The rest of the fields in the BSEG dictionary structure are stored on the database in a compressed format in a single long LRAW field - with multiple lines (BUZEI) for a document packed into a single database record. When you read fields from this table the database passes each LRAW cluster to the application server to be uncompressed into the BSEG field structure - using fields other than the 3 primary key fields in a select WHERE block will slow down performance as SAP has to unpack and look in each cluster to see what matches.
For best performance, get a list of the desired keys from other tables (at least BUKRS and BELNR) and then read the records you want using a FOR ALL ENTRIES IN, or possibly a RANGES table for BELNR if you have a single company code.
SAP has provided some alternate access pathways using other tables to help build the list of document numbers - check tables BKPF, BSIS, BSAS, BSID, BSAD, BSIK, BSAK. Even though you may have to read several of these tables to get the full list of documents you want as each of the BSI* and BSA* tables contains a subset of the BSEG documents, it will still work out quicker than trying to select from BSEG without the key fields. Tables in other modules also may have the company code and FI document number stored to give you the link you need.
Also, BSEG has a lot of fields - so specify the ones you want in the select instead of using SELECT *