Earlier quoted context omitted.
If you only care about storing data and not doing any complex operations or query against it why are you using something like sqlite as well? It’s not a comparison as being in sqlite makes the ability to access this data significantly easier. This is comparing apples and dogs and i don’t see the merits.
It's not uncommon to see people advocate for using sqlite as an alternative to flat files or json blobs. In particular, transactions provide nice properties vs a web of separate flat files, and the stronger schema can be a good alternative to json. There's a lot of great existing sqlite tooling, too.
An unscientific benchmark of SQLite vs. the file system (btrfs)
51–60 of 68 posts
Re: An unscientific benchmark of SQLite vs. the file system (btrfs)
#52Earlier quoted context omitted.
Yeah. I mentioned that in the final test where I write to a temporary file, then rename. This is much slower, probably due to an implicit fsync.
I am not aware of implicit fsyncs. Can you please link to what you are referring to?
[0]: https://www.kernel.org/doc/Documentation/filesystems/ext4.tx...
Edit: note this isn't a universal property either, so it's still wrong: https://btrfs.wiki.kernel.org/index.php/FAQ#What_are_the_cra...
Re: An unscientific benchmark of SQLite vs. the file system (btrfs)
#53Earlier quoted context omitted.
You can disable the fsync calls in sqlite if you wanted to do a little better with this benchmark. You're also explicitly choosing the WAL in your go-sqlite3 configuration which is not at all replicated by your filesystem test. I think, honestly, that you're just going to mislead and confuse people who don't know any better with this writeup. I can write faster to /dev/null, too, but that isn't a very interesting com…
Does /dev/null support sharding?
Re: An unscientific benchmark of SQLite vs. the file system (btrfs)
#54Earlier quoted context omitted.
Easier than SQLite? With less bugs and better tests? SQLite advertises itself as an fopen replacement. Sounds like a perfect match for parent’s use case.
Yes easier, as in time to integrate and get working correctly. I’ve used SQLite extensively over the last 10 years and yes it’s a good solution, but not a replacement for fopen. A flat file would be easier to integrate, test, and harden over SQLite. Would take about the same time as integrating SQLite into a system for the same purpose and would be easily extendable to support features as the system grows.
I find it much easier to add features to my post-2007 projects (when I started using SQLite) for the specific reason that I can open the SQLite file in a GUI and pretty quickly see what’s going on with data organization (schema) and how the customer uses the software I wrote (ie by what columns they actually use/misuse).
Prior to that, there’s various versions of my b-tree library and lots of zips, or linear text indexes, or any combination of whatever fit the need. Data storage implementation needs to be reasoned about in detail for each pre-2007 revisit in ways that don’t happen with SQLite projects.
Re: An unscientific benchmark of SQLite vs. the file system (btrfs)
#55Re: An unscientific benchmark of SQLite vs. the file system (btrfs)
#56Earlier quoted context omitted.
A bad write on a zip file destroys the O(1) seek time, but it doesn't destroy the zip. That goes back to PKZip trying to work on floppies and over modems. You can still do an O(n) seek on a particular file, or expand and recompress the file to recover whatever isn't truncated. For this situation it does matter, but it is recoverable.
Oh interesting! Good to know
For the 32 bit address problem, you could read forward from the front, and as long as no entry was over 4GB, you could still read the file. If the file count was low enough you could cache all of the entry objects, and if reads dominated opens, then you were functionally back to O(1) access (but O(n) startup).
There was a 64 bit extension going around, but when I stopped working with zip files every day I stopped tracking the progress.
Re: An unscientific benchmark of SQLite vs. the file system (btrfs)
#57Earlier quoted context omitted.
Yes easier, as in time to integrate and get working correctly. I’ve used SQLite extensively over the last 10 years and yes it’s a good solution, but not a replacement for fopen. A flat file would be easier to integrate, test, and harden over SQLite. Would take about the same time as integrating SQLite into a system for the same purpose and would be easily extendable to support features as the system grows.
> Would take about the same time as integrating SQLite into a system for the same purpose and would be easily extendable to support features as the system grows. I find it much easier to add features to my post-2007 projects (when I started using SQLite) for the specific reason that I can open the SQLite file in a GUI and pretty quickly see what’s going on with data organization (schema) and how the customer uses the…
Re: An unscientific benchmark of SQLite vs. the file system (btrfs)
#58> we're writing the entire file each time
This is a super-common misunderstanding of Copy-On-Write. Entire files are not re-written on each write to a file. New blocks are written and then the (btree) metadata is updated to include the updated block in the file. [1] This causes greater fragmentation than writing new blocks over old ones in the files existing structure as non-COW systems can do. Another thing which somewhat slows btrfs is all blocks have checksums calculated, stored in metadata and checked on read. If entire files really did need copied on each edit - it would be a great deal slower !
[1] https://btrfs.wiki.kernel.org/index.php/Btrfs_design#Files
Re: An unscientific benchmark of SQLite vs. the file system (btrfs)
#59Earlier quoted context omitted.
It's not uncommon to see people advocate for using sqlite as an alternative to flat files or json blobs. In particular, transactions provide nice properties vs a web of separate flat files, and the stronger schema can be a good alternative to json. There's a lot of great existing sqlite tooling, too.
Not only other people, the creators also advocate for it as a file format: https://www.sqlite.org/aff_short.html https://www.sqlite.org/appfileformat.html
Re: An unscientific benchmark of SQLite vs. the file system (btrfs)
#60(Sadly, it seems like both benchmarks are flawed.)