Requesting offline data with Android SMP SDK data is very slow

287 Views Asked by At

​We are implementing a native Android app using the SAP Mobile Platform SDK 3.0 SP14. The app has serveral offline stores to hold master data locally on the device. The data will only be requested, there is no fetch, because the data will not be changed on the device. Every store has the same, simple Entity type with 4 fields. The last one is a String field, which can have a lenght up to 150 chracters. To access the offline data in a store, the app selects all data at once. But this request is very slow (~ 1,000 items per second). Our largest store has 500,000 items, so requesting this store would have a duration of 500 seconds. Is there a way to speed up the request for the large offline store?

if (offlineStore != null) {
        try {
            //Define the resource path
            String resourcePath = format("%1$s",
                        StoreDefinitions.Data.ENTITY_SET_NAME);

            ODataRequestParamSingle request = new ODataRequestParamSingleDefaultImpl();
            request.setMode(ODataRequestParamSingle.Mode.Read);
            request.setResourcePath(resourcePath);
            //Send a request to read the travel agencies from the local database
            ODataResponseSingle response;

            // executeReadEntitySet: poor performance
            response = offlineStore.executeReadEntitySet(resourcePath, null);
...
2

There are 2 best solutions below

1
atagat On

You can use OData filters and paging options with the offline store APIs in the SMP SDK just as you would with an OData v2 web service. For example, you could add a "$filter=property1 eq 'value'" to your resourcePath string and this would have the same effect as a WHERE clause in a SQL query. For paging, you can use the $top and $skip options with the offline store query.

If you need to actually access 500,000 items at once using the SMP 3.0 SDK, I'm afraid there is no good way to speed up access locally. But it does raise the bigger question as to why you are trying to access such a large number of items on a mobile device?

0
Michael Jess On

The kind of request you are carrying out boils down to a plain and simple table scan on the database level, and unfortunately, there is no way to add request parameters that could speed up this process (i.e. make the database request "simpler"). The only way to make this faster would be to access the database directly, which is no longer supported as of SMP SDK 3.0.

I'd suggest continuing the discussion in the comments, anyway. Perhaps we can figure out an alternative path for you.