FROM : Chris Hanson
DATE : Fri Nov 02 03:04:31 2007
On Nov 1, 2007, at 3:53 PM, Benjámin Salánki wrote:
>> The sqlite database file format won't grow and shrink in response
>> to every change you make, for performance reasons data is mapped to
>> pages which may contain many individual data records (or a single
>> data record can span many pages).
>
> So are you saying removing an item from the store won't reduce its
> size on the disk? How can I tell my users that even if they do
> remove all their data they won't regain any of their precious hard
> disk space? Surely there has to be a way to reduce the size of the
> file if I remove data from it. PLease tell me it's possible.
You asked about removing *an* item. If enough items are removed to
free up a page in the database file, SQLite's automatic database
vacuuming will reduce the size of the file as it rearranges the data
to remove that page. Similarly, the file size may be reduced if you
remove an item that itself occupies multiple pages (such as a
thumbnail image).
An SQLite file is arranged as a collection of pages and the data
within those pages is managed via B-trees, not as simple fixed-length
records (which is what it sounds like you're expecting). This is much
more efficient for searching and for overall storage, since it allows
SQLite to optimize how it stores both data and indexes in a single
file, and is also the foundation of its data integrity (transaction &
journaling) mechanism.
However, the cost of this is that some delete operations may leave
holes in the file. If you delete some data and add other data, the
holes left by the deleted data may be filled by the added data, or the
file may be vacuumed to compact its data, whichever SQLite considers
most appropriate based on the operations you're performing.
Does that make sense?
-- Chris
DATE : Fri Nov 02 03:04:31 2007
On Nov 1, 2007, at 3:53 PM, Benjámin Salánki wrote:
>> The sqlite database file format won't grow and shrink in response
>> to every change you make, for performance reasons data is mapped to
>> pages which may contain many individual data records (or a single
>> data record can span many pages).
>
> So are you saying removing an item from the store won't reduce its
> size on the disk? How can I tell my users that even if they do
> remove all their data they won't regain any of their precious hard
> disk space? Surely there has to be a way to reduce the size of the
> file if I remove data from it. PLease tell me it's possible.
You asked about removing *an* item. If enough items are removed to
free up a page in the database file, SQLite's automatic database
vacuuming will reduce the size of the file as it rearranges the data
to remove that page. Similarly, the file size may be reduced if you
remove an item that itself occupies multiple pages (such as a
thumbnail image).
An SQLite file is arranged as a collection of pages and the data
within those pages is managed via B-trees, not as simple fixed-length
records (which is what it sounds like you're expecting). This is much
more efficient for searching and for overall storage, since it allows
SQLite to optimize how it stores both data and indexes in a single
file, and is also the foundation of its data integrity (transaction &
journaling) mechanism.
However, the cost of this is that some delete operations may leave
holes in the file. If you delete some data and add other data, the
holes left by the deleted data may be filled by the added data, or the
file may be vacuumed to compact its data, whichever SQLite considers
most appropriate based on the operations you're performing.
Does that make sense?
-- Chris
| 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

