Slow data retrieval

Hi,
I need to retrieve data instantly from a table(For ex: 20 entries). Currently, it takes considerable amount of time on 2g as well as on WIFI,3g.
Even when I have a simple table with 2 columns. I am not using any relations. What can I do to decrease the amount of time taken.

Example query:

QueryOptions queryOptions = new QueryOptions();
    queryOptions.addSortByOption("created ASC");
    BackendlessDataQuery backendlessDataQuery = new BackendlessDataQuery();
    backendlessDataQuery.setQueryOptions(queryOptions);
IDataStore<Test> DATA_STORE = Backendless.Persistence.of(Test.class);
    DATA_STORE.find(backendlessDataQuery, new AsyncCallback<BackendlessCollection<Test>>() {
                @Override
                public void handleResponse(BackendlessCollection<Test> response) {
                    callback.handleResponse(response.getCurrentPage());
                }
                @Override
                public void handleFault(BackendlessFault fault) {
                    callback.handleFault(fault);
                }
            }
    );

Do you have any relation columns with “autoload” enabled?

How long do the queries take when you run the code on your computer (with an emulator)?

Mark

There is no auto load enabled for any column nor do i have any relation

What about my second question?

Hi Dear Mark

i Have This Problem!!!

Retrieval is Very Slow By Emulator Android (Genymotion Lasted Version);

And Internet Speed is 5Mb.

10 Sec Delay For First Response.

Sorry For Bad English…

Regards

Beheshtian.

How much data are retrieving?
How complex are the data tables (number of columns, relations)

What does the query look like?

alll data retrieved
just Slow
344 object (text)
and all data stored in local database

local database? You mean Standalone Backendless?

no ormLite in App

You need to share more information before I can suggest (or say) anything. With the amount of information you shared, all I can say “ok, that’s seems like a lot of data. Loading 344 objects into a mobile device seems unreasonable, not a single person can handle so much data at once”.

private void advancedPagingAsync() throws Exception {
long startTime = System.currentTimeMillis();
final int PAGESIZE = 100;

final AsyncCallback<BackendlessCollection<Vahdat>> callback = new AsyncCallback<BackendlessCollection<Vahdat>>() {
    private int offset = 0;
    private boolean firstResponse = true;

    @Override
    public void handleResponse(BackendlessCollection<Vahdat> restaurants) {
        if (firstResponse) {
            total = restaurants.getTotalObjects();
            Log.i(G.TAG, "handleResponse: " + "Total restaurants - " + total);

            firstResponse = false;
        }

        int size = restaurants.getCurrentPage().size();
        Log.i(G.TAG, "handleResponse: " + "Loaded " + size + " restaurants in the current page");

        for (Vahdat vahdat : restaurants.getCurrentPage()) {

            mV v = new mV(vahdat.getMDate(), vahdat.getObjectId(), vahdat.getOwnerId(), vahdat.getMNum(), vahdat.getMText(), vahdat.getMTitle(), vahdat.getCreated(), vahdat.getUpdated());
            G.dbHelper.getVahdateRuntimeExceptionDao().create(v);
        }
        if (size > 0) {
            offset += restaurants.getCurrentPage().size();
            restaurants.getPage(PAGESIZE, offset, this);
        } else {
            if (total != 0)
                G.MSG("بروز رسانی", "تعداد آراء اضافه شده : " + total, "s");

            Log.i(G.TAG, "handleResponse: " + "Down........................");
        }
    }

    @Override
    public void handleFault(BackendlessFault backendlessFault) {
        Log.i(G.TAG, "handleResponse: " + "Error - " + backendlessFault.getMessage());

    }
};

BackendlessDataQuery dataQuery = new BackendlessDataQuery();
if (lastAerDate != null)
    dataQuery.setWhereClause(mV.KEY_updated + " after " + (lastAerDate.getTime()));
dataQuery.setPageSize(PAGESIZE);
Backendless.Data.of(Vahdat.class).find(dataQuery, callback);
if (DIALOG.isShowing())
    DIALOG.dismiss();
Log.i(G.TAG, "handleResponse: " + "Total time (ms) - " + (System.currentTimeMillis() - startTime));

//    System.out.println( "Total time (ms) - " + (System.currentTimeMillis() - startTime ));

}

This makes multiple requests to the server and the time you calculate includes storing objects in the local database.

ok Tnx

So, can I download all the objects from a Table with only one request?

Data is retrieved with paging. Maximum page size is 100:

https://backendless.com/documentation/data/android/data_data_paging.htm