简体   繁体   English

解析本地数据存储区查询需要在Android上花费时间

[英]Parse local datastore query takes time on Android

I have pinned object for first time. 我第一次寄托物。 Next time i try to fetch same object it takes time sometimes like 5 to 6 second in this the screen turns blank. 下次我尝试获取相同的对象时,有时需要5到6秒的时间,屏幕变为空白。

Here is my code for pinning. 这是我的固定代码。 (Both pinning and querying data from local store is done on same table in parse) (来自本地存储的固定和查询数据都在解析中的同一个表上完成)

ParseQuery<ParseObject> query = ParseQuery.getQuery(PARSE_IMAGE_TABLE);
List<ParseObject> images = query.find();

for each image i get i do following:

parseObject.pinInBackground(PARSE_PIN_WALLPAPER_INFO,
                            new SaveCallback() {

                                @Override
                                public void done(ParseException arg0) {
                                    System.out.println();

                                }
                            });

When querying: 查询时:

ParseQuery<ParseObject> query = ParseQuery.getQuery(PARSE_IMAGE_TABLE);
        query.whereEqualTo(PARSE_IMAGE_THUMB_URL, imageURL);
        query.fromLocalDatastore();
        query.fromPin();

List<ParseObject> images = query.find(); -- this call takes time

Yes their is a lot of performance tweaks you can do in your code. 是的,他们在您的代码中可以进行大量的性能调整。 Pinning a list of objects is faster and better approach. 固定对象列表是更快更好的方法。

Instead of using find query use findInBackground. 而不是使用find查询使用findInBackground。

Also start using pin(String name) and fromPin(String name) instead of fromPin() and fromPin(String name). 也开始使用pin(String name)和fromPin(String name)而不是fromPin()和fromPin(String name)。 This has a huge advantage if you have a lot of rows in your parse local storage. 如果您的解析本地存储中有很多行,则这具有巨大的优势。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM