Live data from Hacker News

An unscientific benchmark of SQLite vs. the file system (btrfs)

github.com

41–50 of 68 posts

Re: An unscientific benchmark of SQLite vs. the file system (btrfs)

#41
post #24

How about a fast filesystem? This is by far the slowest.

That’s fair. It’s the file system I have easy access to. I should spin up a VPS and use ext4 or xfs. I may do that when I have some spare time. It looks like I may get double the perf by making that switch. SQLite also seems to get a bump on different file systems. Edit: just ran it on EXT4 on Linode. SQLite: 8.7s EXT4: 18.3s

I’d bet that xfs is the fastest, it usually is

Re: An unscientific benchmark of SQLite vs. the file system (btrfs)

#42

Earlier 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.

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)

#43

Earlier quoted context omitted.

In one application I use sqlite to store JPEG thumbnails. That's it; there's nothing else in there. It's super handy; I specifically needed to reduce the number of files that I open and close because that's slow on Windows/NTFS. SQLite made this trivial. I could have managed a binary pack format on my own but I didn't have to.

You could have easily done that with a single file with a tail header for look ups.

I'm aware; I mentioned this at the end of my post. This is still easier. I want to clearly express how absolutely trivial it was to use SQLite for this. I didn't really have to think about anything.

Re: An unscientific benchmark of SQLite vs. the file system (btrfs)

#44
post #28

Earlier 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.

Depends on the indexing needs, right? Something like IFF should be fine if you need a sequence of images to store that you don’t need to actually query for individually.

Always, but I find it really hard to see how not using SQLite in this use case is the better option. Maybe if you need every single percentile of performance? In 99% of other cases just go with SQLite.

Re: An unscientific benchmark of SQLite vs. the file system (btrfs)

#45
post #4

I couldn't see any fsync (or similar) in your filesystem code (sorry if I missed them) -- it doesn't seem like a completely fair comparison, as sqlite has various promises about commits being completely made, etc, which you won't get from just chucking files on a filesystem.

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.

SQLite makes seeking in a file using a lookup table look like a complex operation from the developer’s perspective, which is absolutely a good thing unless you have a strong alternative rationale for your use case.

Re: An unscientific benchmark of SQLite vs. the file system (btrfs)

#46
post #28

Earlier quoted context omitted.

You could have easily done that with a single file with a tail header for look ups.

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.

Re: An unscientific benchmark of SQLite vs. the file system (btrfs)

#47

Earlier 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?

Yes.

Re: An unscientific benchmark of SQLite vs. the file system (btrfs)

#48

Earlier quoted context omitted.

Go’s the tool I’m using to build a side project, so I was really only curious about Go + SQLite vs Go + file system.

depending on your data, there's also Keyvalue stores like boltdb & badger.

I believe https://github.com/erthink/libmdbx is the highest-throughput transactional KV store with a Golang binding right now. (It’s the current storage backend for https://github.com/ledgerwatch/erigon, which switches quickly to whatever wacky library is optimally performant at the moment.)

Re: An unscientific benchmark of SQLite vs. the file system (btrfs)

#49

I couldn't see any fsync (or similar) in your filesystem code (sorry if I missed them) -- it doesn't seem like a completely fair comparison, as sqlite has various promises about commits being completely made, etc, which you won't get from just chucking files on a filesystem.

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?

Re: An unscientific benchmark of SQLite vs. the file system (btrfs)

#50

I couldn't see any fsync (or similar) in your filesystem code (sorry if I missed them) -- it doesn't seem like a completely fair comparison, as sqlite has various promises about commits being completely made, etc, which you won't get from just chucking files on a filesystem.

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.

There's some 10-year old webpage that used to be popular on HN that goes into data integrity issues and fsync and filesystem databases that someone should dig up so you can read.
Post reply on HN