where Clause Optimization

The JADE compiler and interpreter optimize iterations for a dictionary with a single key, provided that the iteration contains a simple relative key expression in the where clause of the foreach instruction.

The where clause is not optimized if the dictionary key is sorted in descending order.

The optimization consists of recognizing a relative key expression, to start the iteration at the required relative position in the associated dictionary, as follows.

The code fragment in the following example shows the where clause with a relative key expression.

foreach customer in company.allCustomers where customer.name
         > selectedName do
    addToList(customer);
endforeach;

In this example, customer.name is the key of the allCustomers dictionary on company.