2008 Apr 23 10:56 AM
Hi All,
Is there any ABAP syntax which enforces Using the Index.
Hi All,
Is there any ABAP syntax which enforces Using the Index.
2008 Apr 23 11:06 AM
hi,
Indexes can be defined in the ABAP Dictionary to speed up access to data in a table. These indexes are
also created in the database.
An index can be used to speed up the selection of data records from a table.
An index can be considered to be a copy of a database table reduced to certain fields. The data is stored
in sorted form in this copy. This sorting permits fast access to the records of the table (for example using
a binary search). Not all of the fields of the table are contained in the index. The index also contains a
pointer from the index entry to the corresponding table entry to permit all the field contents to be read.
When creating indexes, please note that:
An index can only be used up to the last specified field in the selection! The fields which are specified
in the WHERE clause for a large number of selections should be in the first position.
Only those fields whose values significantly restrict the amount of data are meaningful in an index.
When you change a data record of a table, you must adjust the index sorting. Tables whose contents
are frequently changed therefore should not have too many indexes.
Make sure that the indexes on a table are as disjunct as possible.
The database optimizer decides which index on the table should be used by the database to access
data records.
You must distinguish between the primary index and secondary indexes of a table. The primary index
contains the key fields of the table. The primary index is automatically created in the database when the table is activated. If a large table is frequently accessed such that it is not possible to apply primary index sorting, you should create secondary indexes for the table.
The indexes on a table have a three-character index ID. '0' is reserved for the primary index. Customers can create their own indexes on SAP tables; their IDs must begin with Y or Z.
If the index fields have key function, i.e. they already uniquely identify each record of the table, an index can be called a unique index. This ensures that there are no duplicate index fields in the database.
When you define a secondary index in the ABAP Dictionary, you can specify whether it should be created on the database when it is activated. Some indexes only result in a gain in performance for certain database systems. You can therefore specify a list of database systems when you define an index. The index is then only created on the specified database systems when activated.
READ TABLE wait_list INTO wa_cust INDEX 1.
DELETE wait_list INDEX 1.
INSERT <INTO <itab> INDEX <n>.
READ TABLE <itab> INDEX <n> into <wa>
MODIFY <itab> INDEX <n>.
Hope this helps.
Edited by: Runal Singh on Apr 23, 2008 3:43 PM
2008 Apr 23 11:20 AM
Please have a look at below link for this.
[What to Keep in Mind for Secondary Indexes|http://help.sap.com/saphelp_nw04/helpdata/en/cf/21eb2d446011d189700000e8322d00/frameset.htm]
Also you can use below method to check which index is used when you have excuted your report:
Open a second session and choose System > Utilities > Performance trace.
The Trace Requests screen appears.
Select Trace on.
The SQL trace is activated for your user, that is all the database operations under your user are recorded.
In the first window, perform the action in which the index should be used.
If your database system uses a cost-based optimizer, you should perform this action with as representative data as possible. A cost-based optimizer tries to determine the best index based on the statistics.
In the second session, choose Trace off and then Trace list.
The format of the generated output depends on the database system used. You can determine the index that the database used for your action with the EXPLAIN function for the critical statements (PREPARE, OPEN, REPOPEN).
I hope it helps.
Thanks,
Vibha
Please mark all the useful answers
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |