Comment by somat

1 day ago

Not obvious to me.

A filesystem is a database, it is a type of key value storage. there is a hierarchical lookup key that points you to an unstructured block of data.

Many databases(berkleydb, postgresql, sqlite) are then built on this unstructured database. There is absolutely nothing indicating that putting putting a key value database with hierarchical keys and unstructured blocks in a single file will be slow.

It could be, naive indexing or rebalancing could be very slow. But it does not have to be. In fact berkleydb is a neat case study here. superficially it is a ridiculously simple key value store, why does such a simple thing even need to exist, or have such a long lived presence. It turns out building the efficient structures needed to work with slow non-volatile storage is non-trivial. Early mysql used berkleydb as a low level storage engine. Note that mysql main selling point was speed before correctness.

See also: Virtual machines another ubiquitous case of a filesystem in userspace.

It's something completely different. A database like SQLite runs in the same process as the application

All the filesystem calls go through the kernel. A userspace file system is another process.

It's not like SQLite, it's more like Postgres. Try sending a few hundred thousand small queries to Postgres, and be surprised how slow it's going to be.

The file system api is not like sql that allows complex queries. It's a lot of tiny and simple requests that assume very low latency.