views:

1425

answers:

7

I have an idea for a webapp for the iPhone but its unknown to me how much data can be stored in mobile Safari's SQLite db. I tried searching through the Apple docs but found nothing:

Safari Client-Side Storage and Offline Applications Programming Guide: Using the JavaScript Database

A: 

You are only limited by the amount of free space on the device.

skamradt
A: 

It's as the other posters say. You're only limited by the drive space on the device.

You also need to consider your in memory footprint though. There is a finite amount of memory on the iphone, and in general it's quiet small, so the amount of data/hydrated objects you'll be able to have in memory is another potential limitation for your app.

Bryan McLemore
I thought that since SQLite is based on flat-files, there would be no memory constraints to overall storage. Obviously yes there is a limit to what you can load into memory at one time, but that shouldn't affect file storage right?
Geuis
No it wouldn't affect the storage, just the limit of what you can have in memory at any given time. I mention it because you sound like you are dealing with a fairly large dataset.
Bryan McLemore
This is not the case for Mobile Safari. In my testing it seems you are limited to 50MB.
Peter Wagenet
A: 

I'm not sure. If you were doing your own application you'd be limited by free space on the device and to some extent in memory footprint (as Bryan McLemore points out).

However since you're looking at using JavaScript inside of Safari there's no easy way to tell. According to the document you found it looks like it may be limited by site, but there's nothing telling you how much. I'd suggest writing a quick script to fill up the database and figure out how much it actually is. After that, I'd probably halve that value and assume I'd be always be able to use that much.

Be sure to report back so we'll all know!

Epsilon Prime
Oh, and note to all reading this -- go to the documentation link mentioned in the question and add a comment suggest to Apple that the document be updated.
Epsilon Prime
A: 

It's most likely 32 terabytes... which is well over the available disk space.

I reached this number by multiplying the maximum page size by the maximum page count listed at the bottom of the SQLite limits page.

jessecurry
A: 

Limits In SQLite

"Limits" in the context of this article means sizes or quantities that can not be exceeded. We are concerned with things like the maximum number of bytes in a BLOB or the maximum number of columns in a table.

SQLite was originally designed with a policy of avoiding arbitrary limits. Of course, every program that runs on a machine with finite memory and disk space has limits of some kind. But in SQLite, those limits were not well defined. The policy was that if it would fit in memory and you could count it with a 32-bit integer, then it should work.

Unfortunately, the no-limits policy has been shown to create problems. Because the upper bounds were not well defined, they were not tested, and bugs (including possible security exploits) were often found when pushing SQLite to extremes. For this reason, newer versions of SQLite have well-defined limits and those limits are tested as part of the test suite. As of version 3.6.19 (all statistics in the report are against that release of SQLite), the SQLite library consists of approximately 65.7 KSLOC of C code. (KSLOC means thousands of "Source Lines Of Code" or, in other words, lines of code excluding blank lines and comments.) By comparison, the project has 690 times as much test code and test scripts - 45409.7 KSLOC.

Tariq- iPHONE Programmer
A: 

The default storage limit on iPhone seems to be 5mb

Wayne
+5  A: 

Most of these answers are totally wrong. Safari will not allow you to create SQLite databases over 50MB (or expand existing databases beyond that size).

This is a limit imposed by Safari - as other people have noted, SQLite itself supports much larger databases that you can use from native apps. But webapps are limited to 50MB.

It might be useful to note that this is per database - if you really need the extra space, you can create multiple databases, although this would obviously cause a lot of hassle.

Ironfrost
I've also confirmed the 50MB limit on a single database. Are you sure that this is a per database limit not an overall site limit?
Peter Wagenet
50MB limit is per DB. And permission is asked only for the first 50MB DB you create.
newtonapple