Performance issues - plist vs sqlite on iOS

I need to track some variables and save them very often. I do not need complex search and sorting, just read / write.

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

Besides the above two methods, should kernel data be used?

Please give me some advice.

Thanks.

+4
source share
3 answers

In SQlite, you can perform all the functions related to SQL, such as create, delete..and also store a large amount of data. But in Plist you will find it jst store.

Plist and SQLite have various uses, as shown below.

PList is a file format used to store a small amount of structural data (less than a few hundred kilobytes), usually a dictionary. PList does not have the ability to sort by itself, although the code can be easily written to sort it. The property list is probably the easiest to maintain, but it will be loaded into memory right away. This can lead to a large amount of device memory.

SQLite is a complete database. The file size (on iphone) is essentially unlimited. Embedded sorting capabilities. Queries and relational tables are possible. Performance should be as good as any sorting algorithm you could come up with. The sqlite database, on the other hand, only downloads the data you request. I'm not sure how your data is structured, but you could easily create key-value pairs with a single database table. (One table with a key column and a column of values). Then, if it were me, I would write an Objective-C class to wrap database queries so that I can write simple instructions, for example:

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

Obtaining data in a database in the first place should not be difficult. You can use the sqlite3 command line utility to bulk upload your data. There is a team called .import that will import your data from a text file.

+7
source

From @Robert Harvey's answer in this previous SO question plist or sqlite

PList is a file format used to store a small amount of structural data (less than a few hundred kilobytes), usually a dictionary. PList do not have the ability to sort into itself, although the code can be easy to sort. The list of properties is perhaps easiest to maintain, but it will be loaded into memory once. It can eat a lot of device memory.

SQLite is a complete database. File size (on iphone): virtually unlimited. Sorting capabilities are built-in. Query and relational tables are possible. Performance should be as good as any sorting algorithm you may encounter. In the sqlite database, on the other hand, it will only load the data you request. I'm not sure how your data is structured, but you can pretty easily create key-value pairs with a single database table.

If you store "huge data" then you will benefit from sqlite. Especially if you are going to perform complex queries, retrieve, search and sort, etc.

+3
source

If you intend to perform operations such as search, do a sort, you must use sqlite. In sqlite we can store a large amount of data, but this is not possible in plist.I don’t know about performace between this.

0
source

All Articles