IOS工程师面试被问到的问题SQLite store takes a "long time" to save怎么解决?
来源:互联网 发布:淘宝网店流量数据分析 编辑:程序博客网 时间:2024/06/07 08:01
官方文档的描述和回答:
Problem: You are using an SQLite store and notice that it takeslonger to save to the SQLite store than it does to save the same data to an XMLstore.
Cause: This is probably expected behavior. The SQLite store ensures that all data is written correctly to disk—see“Configuringa SQLite Store’s Save Behavior.”
Remedy: First determine whether the time taken to save will benoticeable to the user. This is typically likely to be the case only if youconfigure your application to frequently save automatically—for example, afterevery edit that the user makes. First, consider changing the store’s save behavior (switch off full sync). Then consider saving data only after a setperiod (for example, every 15 seconds) instead of after every edit. Ifnecessary, consider choosing a different store—for example, the binary store.
解决卡顿的方法:
1 关闭fullfsync,然后调整频率
NSPersistentStoreCoordinator *psc = <#Get a persistent store coordinator#>;
NSMutableDictionary *pragmaOptions = [NSMutableDictionary dictionary];
[pragmaOptions setObject:@"NORMAL" forKey:@"synchronous"];
[pragmaOptions setObject:@"1" forKey:@"fullfsync"];
NSDictionary *storeOptions =
[NSDictionary dictionaryWithObject:pragmaOptions forKey:NSSQLitePragmasOption];
NSPersistentStore *store;
NSError *error = nil;
store = [psc addPersistentStoreWithType:NSSQLiteStoreType
configuration: nil
URL:url
options:storeOptions
error:&error];
2如果还不满意,自己去手工每15秒调用保存(卡顿)方法,算是负载均衡(不知是否用多线程)
3使用二进制的数据流,就不会出现此问题.
- IOS工程师面试被问到的问题SQLite store takes a "long time" to save怎么解决?
- IOS:知乎上的一个怎么面试iOS工程师的问题
- Running "uglify:generated" (uglify) task takes a very long time.
- 知乎上的一个怎么面试iOS工程师的问题
- [转]知乎上的一个怎么面试iOS工程师的问题
- 知乎上的一个怎么面试iOS工程师的问题
- dubbo的Failed to save registry store file问题
- jmap-permstat-takes-long-time-and-hangs
- To be a great man, To save your time first!
- Can't believe it takes me so long to do a so easy thing in sql
- 【IOS学习】面试iOS工程师的相关问题
- sudo command last a long time to execute
- 面试iOS开发工程师职位遇到的问题
- Android save img to sqlite
- 怎么解决App Store的搜索难题?
- What It Takes to Make a Student
- What It Takes To Make a Student?
- 驱动工程师的面试问题。
- 明天要下雪啦,"表达式"笔记
- BNE_UIX_PHYSICAL_DIRECTORY is not configured.
- 开通博客三天内不允许发表文章
- jquery遍历
- C++中的this指针
- IOS工程师面试被问到的问题SQLite store takes a "long time" to save怎么解决?
- javascript简单的反转器.
- 数制转换 递归实现
- 随便输一个数,从大到小排序
- sicily 1762
- LUA常见库和工具
- DRAM, SRAM, SDRAM的关系与区别
- 寻找1000以内的完数 JAVA
- 1000以内的完数