性能问题 - iOS中的plist vs sqlite [英] Performance issue - plist vs sqlite in iOS

查看:87
本文介绍了性能问题 - iOS中的plist vs sqlite的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要跟踪一些变量并经常保存它们。我不需要复杂的搜索和排序,只需简单的读/写。

I need to keep track of some variables and to save them very frequently. I don't need complex search and sort, just simple read/write.

plist和sqlite之间的读/写性能有什么不同?

What is the difference in read/write performance between plist and sqlite ?

除了上述两种方法外,我应该使用核心数据吗?

Besides the above two methods, should I use core data ?

请给我一些提示。

谢谢。

推荐答案

在SQlite中,您可以执行所有与SQL相关的功能,如创建,删除..并且还存储了大量的数据。但是在Plist中你的jst商店。

In SQlite you can perform all functions related SQL like create,delete..and also store large amount of data.But in Plist its you jst store .

Plist和SQLite的用法如下所示..

Plist and SQLite have different use as below..

PList是一种文件格式,用于存储少量结构数据(少于几百千字节),通常是字典。 PList本身没有排序功能,尽管可以轻松编写代码来对其进行排序。
属性列表可能是最容易维护的,但它会一次性加载到内存中。这可能会占用设备的大量内存

PList is a file format used to store a small amount of structural data (less than a few hundred kilobytes), typically a dictionary. PList doesn't have sorting capabilities in and of itself, although code can easily be written to sort it. A property list is probably the easiest to maintain, but it will be loaded into memory all at once. This could eat up a lot of the device's memory

SQLite是一个成熟的数据库。文件大小(在iPhone上)基本上是无限的。内置排序功能。查询和关系表设计是可能的。性能应该与您可能提出的任何排序算法一样好。
另一方面,sqlite数据库只会加载您请求的数据。我不确定您的数据是如何构建的,但您可以使用单个数据库表轻松创建键值对。 (带有键列和值列的单个表)然后,如果是我,我会编写一个Objective-C类来包装数据库查询,这样我就可以编写简单的语句,如:

SQLite is a full-fledged database. File sizes (on an iphone) are essentially unlimited. Sorting capabilities are built in. Querying and relational table designs are possible. Performance should be as good as any sorting algorithm you might come up with. An sqlite database, on the other hand, will load only the data you request. I'm not sure how your data is structured, but you could quite easily create key-value pairs with a single database table. (A single table with a key column and a value column) Then, if it were me, I'd write an Objective-C class to wrap the database queries so I can write easy statements like:

NSString *welcomeText = [[MyData sharedData] dataWithKey:@"WelcomeText"];

首先将数据输入数据库并不困难。您可以使用命令行sqlite3实用程序批量加载数据。有一个名为.import的命令,它将从文本文件中导入数据。

Getting the data into the database in the first place doesn't have to be difficult. You can use the command line sqlite3 utility to bulk load your data. There's a command called .import that will import your data from a text file.

这篇关于性能问题 - iOS中的plist vs sqlite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆