2008 Mar 20 3:16 PM
How do u write the Select statement for Primary Index and Secondary Index?
How do u write the Select statement for Primary Index and Secondary Index?
2008 Mar 20 3:21 PM
I think the determination is done by SAP at runtime. The best way is to make sure all the fields in your secondary index are used in the where condition of the select statement.
-Cheers
2008 Mar 20 3:44 PM
Hi,
Order of the fields is also important in the where clause.
Lets say you are selecting from vbap
the primay key is VBELN and POSNR. you should mention VBELN first then POSNR in the where clause.
select * from vbap into it_vbap
where vbeln = p_vbeln " parameter on selection screen
and posnr = p_posnr. " parameter on selection screen
Similarly for any secodnary index also you should specify the order of the fields in the same order as mentioned in the index.
2008 Mar 20 3:44 PM
Database optimizer will decide on usage of the index based on the where clause. We cant force the system to use selected index.
2008 Mar 20 3:49 PM
Hi Krishna,
You provide columns(on which indexing is done) in the where clause of select statement.
However, the order is important here because filtering of records based on your where clause will be done in the order you provide your filtering conditions.
Good practice is to provide all the indexes first and then other filtering criteria in your where clause.
G@urav.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |