Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Performance issue - plist vs sqlite in iOS

Tags:

ios

iphone

ipad

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.

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

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

Please give me some hints.

Thanks.

like image 764
user403015 Avatar asked Dec 27 '22 20:12

user403015


2 Answers

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 and SQLite have different use as below..

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 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"];

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.

like image 94
sinh99 Avatar answered Jan 13 '23 11:01

sinh99


From the answer provided by @Robert Harvey 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), 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 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.

If you are storing "huge data" then you will benefit from sqlite. Especially if you are going to be performing complex queries, extraction, searching and sorting etc..

like image 42
visakh7 Avatar answered Jan 13 '23 11:01

visakh7