On Tue, May 3, 2011 at 4:44 PM, Sugathan, Rupesh <r...@carriercomm.com> wrote: > I am planning to use sqlite on a Linux system with JFFS2 file system on > NAND flash. NAND device that I am using has page size of 2048 bytes and > a erase sector size of 128K. I would like to take advantage of sqlite > rollback for the safety of my database files during power-fail. > > As per http://www.sqlite.org/pragma.html#pragma_page_size, the PAGE_SIZE > should be set between 512 bytes and 64K. The page size of NAND devices, > in my understanding, is only good for 2 to 3 writes before needing to > erase the whole sector. This indicate that the PAGE_SIZE in this case > should be set to 128K (the erase size). Given that this is not a > possibility, how is the power-fail safety achieved in sqlite used on > large sectored flash devices?
I do not have specific experience to share, but I think your reasoning is wrong. If you set the SQLite page size to 128kb, then any time SQLite needs to write anything, it's going to write an entire erase sector. Even if SQLite is just updating a tiny piece of data in the middle of a page. That seems like the worst thing you could do. You probably rather want your PAGE_SIZE set to the size which minimizes the amount of overall data written for your workload, keeping in mind that smaller pages mean more overhead in SQLite and the filesystem (so it's not a straight linear function). I think you misunderstand the number of writes per erase sector, too. My understanding is that erase clears the sector, and that you can write each individual page within the sector before needing to erase again. You just cannot re-write an individual page. So PAGE_SIZE of 2048 should work, though you'll have to consider your workload to see if it is the best selection. BTW, in case it wasn't clear, it's really impossible to answer this question without building a system to simulate your workload. Most likely your filesystem driver can be run against non-flash backing stores, and you can probably pull stats from it about how often it writes pages and how often it needs to rearrange pages for purposes of erasing a sector. If it doesn't have such stats, you should complain over there and/or add them yourself. Because all we can do over here is make theories, and what you really want to know is what's going to happen in real life. -scott _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users