简体   繁体   English

在 iPhone 上打开与 SQLITE 数据库的连接太慢

[英]Opening connection to SQLITE database on iPhone too slow

I have created a simple iPhone/iPad app which reads some data from a SQLITE database and shows it on the screen.我创建了一个简单的 iPhone/iPad 应用程序,它从 SQLITE 数据库读取一些数据并将其显示在屏幕上。 The database is added to the Xcode project and only needs to be read (not written).数据库添加到Xcode项目中,只需要读(不用写)。 In the simulator all this works fine, but when I run this app on my iPhone it is too slow.在模拟器中这一切工作正常,但当我在我的 iPhone 上运行这个应用程序时它太慢了。

I have added some performance profiling to the app, so I was able to determine which part of the app was slow.我向应用程序添加了一些性能分析,因此我能够确定应用程序的哪个部分运行缓慢。 It appears that opening the connection to the database takes about 0.8 - 0.9 second on the iPhone and about 0.004 second on the iPad. I tested with the SQLLITE framework and also with the FMDB wrapper, but the results were the same.似乎打开数据库连接在 iPhone 上大约需要 0.8 - 0.9 秒,在 iPad 上大约需要 0.004 秒。我用 SQLLITE 框架和 FMDB 包装器进行了测试,但结果是一样的。

Why is it so slow on the iPhone?为什么在 iPhone 上这么慢? Is there a way to improve the performance?有没有办法提高性能?

Thanks, Danny谢谢,丹尼

How often are you opening it?你多久打开一次? If you can open it once, and just keep that handle open and reuse it, that would likely solve your problem.如果您可以打开它一次,并保持该句柄打开并重复使用它,那很可能会解决您的问题。

Or is it that this single instance of it opening is too great of a burden?还是它打开的这个单一实例负担太大了?

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

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