Jens, Simon,

thanks for your feedback and suggestions. I will take a closer look at keeping 
a "shadow“ copy in the current location and copy the file to the Documents 
folder when needed. That seems to be a feasible approach, especially with what 
Jens wrote about APFS and its copy-on-write support. I’ve completely forgotten 
that. :-)

Thanks
Arno

> Am 24.10.2017 um 19:07 schrieb Jens Alfke <j...@mooseyard.com>:
> 
> 
> 
>> On Oct 24, 2017, at 8:14 AM, Arno Gramatke <ar...@meyersound.com> wrote:
>> 
>> My first naive approach was to figure out, which commands will result in a 
>> read and which will result in a write to the db file. 
> 
> I think you’ll need to assume that any SQLite access can both read and write 
> the file. So at a high level, you should use the NSFileCoordinator to request 
> access before an activity that can cause queries or database writes.
> 
> If you want to avoid requesting write access too often, you could open the 
> database read-only; then you’d know SQLite would only be reading. When you 
> need to make a change you could open another handle with write access just 
> for that transaction.
> 
>> Another idea was to copy the db from the file into an in-memory database 
>> using file coordination, make all modifications in-memory and then copy the 
>> in-memory back to the file system.
> 
> Why not copy it on-disk? iOS 10.3 or later has the APFS filesystem, which is 
> copy-on-write at the block level, making it extremely cheap to copy files. So 
> the initial copy operation will be nearly instant and consume nearly zero 
> disk space, and subsequent changes will use space only for the disk blocks 
> that SQLite changes or adds. Likewise, copying the file back should be 
> instant too.
> 
> —Jens
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to