简体   繁体   中英

iPhone Core Data - optimize queries for performance

I have issues with Core Data performance on iPhone.

I'm developing something like quiz application, with questions and statistics stored in Core Data. On one screen I need to display many statistic info, based on stored data. Now I have over 40 single requests to db, which takes huge amount of time. I think how to optimize this.

I have some experience in classic db systems (like MySQL), so I consider for example some kind of grouping of results, but I haven't found good example.

Another idea, is to make some kind of sql UNION, to perform only one request, fetching all needed data. Is this possible somehow in Core Data?

Any other ideas how to improve performance in my app?

My answer would be to get everything from your sqlite db into arrays and dictionaries and perform the maths on them like that. :) I'm sure that performing 40 mathematical algorithms on arrays and dictionaries is a hell of a lot less painful than performing 40 sqlite queries. :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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