title: Optimize LOOP AT with conditions =, >=, <= in WHERE
body: <p>My internal table contains a lot of data.</p>
  
  <p>I have the following code:</p>
  
  <pre><code>LOOP AT lt_tab INTO ls_tab
    WHERE value1 EQ lv_id1
      AND value2 LE lv_id2
      AND value3 GE lv_id3.
  
    IF ls_tab-value4 IS NOT INITIAL.
      IF ls_tab-value4 NE lv_var.
        lv_flag = lc_var.
        EXIT.
      ENDIF.
    ELSE.
      lv_flag = lc_var.
      EXIT.
    ENDIF.
  ENDLOOP.
  </code></pre>
  
  <p>The database table contains 7 fields and the internal table has the same type like the database table.</p>
  
  <p>In the where clause there are no primary key fields.</p>
  
  <p>There is a composite key in the table that consists of two primary keys. The table fields are <code>transid</code>(primary key), <code>item1</code>(primary key), <code>value1</code>, <code>value2</code>, <code>value3</code> and <code>value4</code>. </p>
  
  <p>I have to search the table based on those conditions only. But this is taking too much time. How to optimize it?</p>