FROM : Benjámin Salánki
DATE : Sun Nov 04 17:37:22 2007
On Nov 3, 2007, at 11:58 PM, Ben Trumbull wrote:
>> My problem is, that if I include a huge amount of data like an
>> uncompressed image that will swell the SQLite file to 72MB,
>
> Generally, large media files should be stored externally to the
> database, and a URI and metadata for it stored in a database record.
I know, I was just testing to see if larger amounts of data would make
any difference.
>
>
>> removing the item does not reduce the file size. I found that if I
>> add another
>> item later that should be around the same size the file size does not
>> change so what you wrote makes sense in that the "holes" inside the
>> file are filled up with new data but I can't get the file size to
>> reduce even by a few bytes.
>
> What you're seeing is internal fragmentation.
>
>> I was thinking of maybe implementing a "consolidate database"
>> function
>> that would load the data from the file to memory, remove the file and
>> recreate the items which would reduce the file size if I am correct.
>
> That's very expensive.
>
>> Or does anyone have a better solution?
>
> Yes. You can manually vacuum an SQLite database with:
>
> sqlite3 filename "vacuum"
>
Very nice, this should do the trick. Thanks for the help!
ben
> Programmatically, you can use an NSTask.
>
> - Ben
>
DATE : Sun Nov 04 17:37:22 2007
On Nov 3, 2007, at 11:58 PM, Ben Trumbull wrote:
>> My problem is, that if I include a huge amount of data like an
>> uncompressed image that will swell the SQLite file to 72MB,
>
> Generally, large media files should be stored externally to the
> database, and a URI and metadata for it stored in a database record.
I know, I was just testing to see if larger amounts of data would make
any difference.
>
>
>> removing the item does not reduce the file size. I found that if I
>> add another
>> item later that should be around the same size the file size does not
>> change so what you wrote makes sense in that the "holes" inside the
>> file are filled up with new data but I can't get the file size to
>> reduce even by a few bytes.
>
> What you're seeing is internal fragmentation.
>
>> I was thinking of maybe implementing a "consolidate database"
>> function
>> that would load the data from the file to memory, remove the file and
>> recreate the items which would reduce the file size if I am correct.
>
> That's very expensive.
>
>> Or does anyone have a better solution?
>
> Yes. You can manually vacuum an SQLite database with:
>
> sqlite3 filename "vacuum"
>
Very nice, this should do the trick. Thanks for the help!
ben
> Programmatically, you can use an NSTask.
>
> - Ben
>
| Related mails | Author | Date |
|---|---|---|
| Benjámin Salánki | Nov 1, 10:04 | |
| Adam Swift | Nov 1, 23:40 | |
| Benjámin Salánki | Nov 1, 23:53 | |
| Chris Hanson | Nov 2, 03:04 | |
| Benjámin Salánki | Nov 3, 21:09 | |
| Ben Trumbull | Nov 3, 23:58 | |
| Benjámin Salánki | Nov 4, 17:37 | |
| Bill Bumgarner | Nov 4, 17:59 |






Cocoa mail archive

