Skip to Content
0
Former Member
Sep 09, 2011 at 09:27 PM

how does select stmt with for all entries uses Indexes

301 Views

Hello all,

I goes through a number of documents but still confused how does select for all entries uses indexes if fields are not in sequences. i got pretty much the same results if i take like two cases on Hr tables HRP1000 and HRP1001(with for all entries based upon hrp1000). Here is the sequence of index fields on hrp1001 (MANDT, OTYPE, OBJID, PLVAR, RSIGN, RELAT, ISTAT, PRIOX, BEGDA, ENDDA, VARYF, SEQNR). in second case objid field is in sequence as in defined Index but i dont see significant increase in field even though the number of records are around 30000. My question is does it make a differrence to use field sequence (same as in table indexes) in comparison to redundant field sequence (not same as defined in table indexes), secondly how we can ge tto know if table index is used in Select for entries query i tried Explain in ST05 but its not clear if it uses any index at all in hrp1001 read.

here is the sample code i use to get test results.

test case 1

REPORT  zdemo_perf_select.

DATA: it_hrp1000 TYPE STANDARD TABLE OF hrp1000 WITH HEADER LINE.
DATA: it_hrp1001 TYPE STANDARD TABLE OF hrp1001 WITH HEADER LINE.
DATA: it_hrp1007 TYPE STANDARD TABLE OF hrp1007 WITH HEADER LINE.
DATA: it_pa0000 TYPE STANDARD TABLE OF pa0000 WITH HEADER LINE.
DATA: it_pa0001 TYPE STANDARD TABLE OF pa0001 WITH HEADER LINE.
DATA: it_pa0002 TYPE STANDARD TABLE OF pa0002 WITH HEADER LINE.
DATA: it_pa0105_10 TYPE STANDARD TABLE OF pa0105 WITH HEADER LINE.
DATA: it_pa0105_20 TYPE STANDARD TABLE OF pa0105 WITH HEADER LINE.

DATA: t1 TYPE timestampl,
      t2 TYPE timestampl,
      t3 TYPE timestampl  
SELECT * FROM hrp1000 CLIENT SPECIFIED  INTO TABLE it_hrp1000 bypassing buffer
            WHERE mandt EQ sy-mandt AND
                  plvar EQ '01' AND
                  otype EQ 'S'AND
                  istat EQ '1' AND
                  begda <= sy-datum AND
                  endda >= sy-datum AND
                  langu EQ 'EN'.

GET TIME STAMP FIELD t1.
SELECT * FROM hrp1001 CLIENT SPECIFIED INTO TABLE it_hrp1001 bypassing buffer
            FOR ALL ENTRIES IN it_hrp1000
             WHERE mandt EQ sy-mandt AND
                    otype EQ 'S' AND
*                    objid EQ it_hrp1000-objid and
                    plvar EQ '01' AND
                    rsign EQ 'B' AND
                    relat EQ '007' AND
                    istat EQ '1' AND
                    begda LT sy-datum AND
                    endda GT sy-datum and
                    sclas EQ 'C' and
                    objid EQ it_hrp1000-objid.
*                    %_hints mssqlnt 'INDEX(HRP1001~0)'.
*delete it_hrp1001 where sclas ne 'C'.
GET TIME STAMP FIELD t2.
t3 = t1 - t2.
WRITE: 'Time taken - ', t3.

test case 2

REPORT  zdemo_perf_select.

DATA: it_hrp1000 TYPE STANDARD TABLE OF hrp1000 WITH HEADER LINE.
DATA: it_hrp1001 TYPE STANDARD TABLE OF hrp1001 WITH HEADER LINE.
DATA: it_hrp1007 TYPE STANDARD TABLE OF hrp1007 WITH HEADER LINE.
DATA: it_pa0000 TYPE STANDARD TABLE OF pa0000 WITH HEADER LINE.
DATA: it_pa0001 TYPE STANDARD TABLE OF pa0001 WITH HEADER LINE.
DATA: it_pa0002 TYPE STANDARD TABLE OF pa0002 WITH HEADER LINE.
DATA: it_pa0105_10 TYPE STANDARD TABLE OF pa0105 WITH HEADER LINE.
DATA: it_pa0105_20 TYPE STANDARD TABLE OF pa0105 WITH HEADER LINE.
DATA: t1 TYPE timestampl,
      t2 TYPE timestampl,
      t3 TYPE timestampl  
SELECT * FROM hrp1000 CLIENT SPECIFIED  INTO TABLE it_hrp1000 bypassing buffer
            WHERE mandt EQ sy-mandt AND
                  plvar EQ '01' AND
                  otype EQ 'S'AND
                  istat EQ '1' AND
                  begda <= sy-datum AND
                  endda >= sy-datum AND
                  langu EQ 'EN'.

GET TIME STAMP FIELD t1.
SELECT * FROM hrp1001 CLIENT SPECIFIED INTO TABLE it_hrp1001 bypassing buffer
            FOR ALL ENTRIES IN it_hrp1000
             WHERE mandt EQ sy-mandt AND
                    otype EQ 'S' AND
                    objid EQ it_hrp1000-objid and
                    plvar EQ '01' AND
                    rsign EQ 'B' AND
                    relat EQ '007' AND
                    istat EQ '1' AND
                    begda LT sy-datum AND
                    endda GT sy-datum and
                    sclas EQ 'C'." and
*                    objid EQ it_hrp1000-objid.
*                    %_hints mssqlnt 'INDEX(HRP1001~0)'.
*delete it_hrp1001 where sclas ne 'C'.
GET TIME STAMP FIELD t2.
t3 = t1 - t2.
WRITE: 'Time taken - ', t3.