Simon Slavin wrote:
On 16 Aug 2014, at 9:32pm, Baruch Burstein <bmburst...@gmail.com> wrote:
On Fri, Aug 15, 2014 at 10:45 AM, Levente <leventel...@gmail.com> wrote:
I am thinking about putting an SQLite database on a flash drive (SD card).
I would like to know what kind of file system is the optimal. I want to
query a lot, and insert or update a few times per minute.
Not directly related to your question, but I am curious: Since sqlite's
atomicity guarantee assumes that write to a disk sector are linear (e.g.
either beginning to end or end to beginning, but never the middle before
either end),
Mmm ... no. SQLite's atomicity assumes in-order execution of writes. In other
words that the changes to the storage device will be done in the order they are
requested. Anything else breaks ACID. However, SQLite does a lot of things to
try and avoid a corrupted database even if ACID is broken, in an effort to let
you rescue the maximum amount of data even if something went wrong with
hardware. Removing all the 'paranoid about hardware' and 'rescue' code from
SQLite would make it significantly smaller.
I was wondering if this assumption was ever verified for flash
drives. I have no information to contrary, but while that assumption makes
a lot of sense for a spinning disk, I see no reason to assume this for
flash drives and other SSDs. I would think that they may parallelize writes
to different parts of the "sector" for efficiency.
Current Flash chips are optimized for sequential writes - while they allow
writes to a sector in random order, doing so requires sending a new row
address for each random access. Meanwhile, if you simply write them
sequentially the write address auto-increments. Since operating systems always
perform whole-sector writes (indeed, they perform whole-page writes) to
current storage devices, and they use a DMA controller which is programmed
with a start address and a block length, you can safely assume that they are
writing each sector sequentially.
There is no efficiency gain in writing multiple sections of a single sector in
parallel. (In fact it is an efficiency loss.) Multi-channel SSDs parallelize
across multiple Flash chips, sending whole sectors to each separate channel/chip.
A good question. By which I mean it's one people should worry about, not one
which we're not sure about.
--
-- Howard Chu
CTO, Symas Corp. http://www.symas.com
Director, Highland Sun http://highlandsun.com/hyc/
Chief Architect, OpenLDAP http://www.openldap.org/project/
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users