Ask HN: Why don't non-relational databases just treat rows as files?
Assuming the operating system's file system is built on some B+tree, the filename is the key (a UUID) and IO calls like fopen() and fclose() will have O(logn) access time. Files, while being modified, can be locked to prevent race conditions. Yes, there is inode overhead (1 million files in a folder is ~40MB), but I'm not using a 1994 desktop machine anymore.
What am I missing?
3 comments
[ 5.2 ms ] story [ 31.1 ms ] threadIn Microsoft Windows locks have a lot more authority, such that it is possible for two Windows machines to connect to a Microsoft Access database (file-based, a lot like sqllite) over a file share and not conflict with each other.
Windows machines go out to lunch a lot waiting for locks to clear so that is your tradeoff.
That is just reads.
If you include writes + transaction logs + join queries etc., individual files become unwieldy very soon.
Also, read/write efficiency decreases by an average of 50% because of this wasted space. It's similar to why backup programs (I'm the author of HashBackup) seem to go so slow on small files: if the average file size is 96 bytes, 4000 bytes (more than 97%) of I/O time is wasted reading such small files.