Skip to content

Execution Order of Defining Queries

SAP Mobile Services executes OData requests to an OData back end based on defining queries one at a time. The order is influenced by three factors:

  • Defining query order mobile services follows this order to send requests to a back end. There are three ways to set the order, as described in the "Defining Query Order" section.

  • Defining query group Defining queries can be split into different groups. The defining queries inside each group will be sent as a batch to a back end and the order inside a group should follow the order defined in the defining query order. The sequence of different groups is decided by the order of the defining queries that occur earliest. The group of defining queries can be defined at either the server-side or client-side. This is described in detail below.

  • Multiple threads download By default, mobile services uses a single thread to send requests to the back end one at a time. To improve performance, you can use multiple threads to send requests.

Defining Query Order

You can configure defining query order using one of three methods:

  • Set OfflineODataParameters.refreshInOrderOfAddition at the client side SAP Mobile Services sends requests to the OData back-end using the addition order of defining queries at the client side. Previous versions of the SDK did not record the addition order of defining queries because they did not support refreshInOrderOfAddition. To ensure defining queries that were added using previous versions of the SDK are executed in the order of addition, you should remove the local store and download it again, or remove and add all the defining queries again in order. If OfflineODataParameters.refreshInOrderOfAddition is set to true, the methods described below are ignored.

  • Set refresh_in_order at server side Set this method using Customization Configuration in the endpoint configuration on the server side. mobile services will then send requests to the OData back end using the order defined on the server side.

  • No configuration by default If the preceding two methods are not used, mobile services will send requests to the OData back end using the alphabetical order of the query names.

Defining Query Group

You can configure defining query groups using one of three methods:

  • Call OfflineODataProvider.setDefiningQueryGroups() on the client side The client can use this method to explicitly set groups. If this is called, the two methods described below are ignored.

  • Enable "batch all" on the server side Select Batch All Defining Requests in the server side's endpoint configuration. When this is set, all defining queries will be grouped in one batch, multiple threads download will not be allowed, and the request group method, if configured, is ignored.

  • Configure "request group" on the server side Set Request Group in Mobile Offline Access configuration.

Multiple Threads Download

Because defining queries have dependencies on each other, some requests need to be sent before others and should not be sent in parallel.

A workaround for this issue is to assign a phase number to each defining query. Defining queries that have the same phase number can be downloaded in parallel. Defining queries with higher phase numbers should be sent after defining queries with smaller phase numbers.

Note that if multiple threads download is enabled, defining query order has no effect and the order will be controlled by the defining query's phase number. The order of defining queries that have the same phase number is undefined, due to the fact that they will be executed in random order by parallel threads.

All defining queries in the same group should have the same phase number and should be executed by a single thread. This means that multiple threads download respects the defining query group, but will not respect the defining query order.

To enable this method, set Download Threads to a value higher than 1 in the endpoint configuration on the server side. Set the phase number in Download Order in the Defining Request section of Mobile Offline Access. configuration.


Last update: June 8, 2022