Do you even need a database?
131–140 of 311 posts
Re: Do you even need a database?
#132Re: Do you even need a database?
#133At some point, don't you just end up making a low-quality, poorly-tested reinvention of SQLite by doing this and adding features?
As soon as you need to do a JOIN, you're either rewriting a database or replatforming on Sqlite.
Re: Do you even need a database?
#134At some point, don't you just end up making a low-quality, poorly-tested reinvention of SQLite by doing this and adding features?
“You Aren’t Gonna Need It” - one of the most important software principles. Wait until you actually need it.
In this case, I feel like using the filesystem directly is the opposite: doing much more difficult programming and creating more complex code, in order to do less.
It depends on how you weigh the cost of the additional dependency that lets you write simpler code, of course, but I think in this case adding a SQLite dependency is a lower long-term maintenance burden than writing code to make atomic file writes.
The original post isn't about simplicity, though. It's about performance. They claim they achieved better performance by using the filesystem directly, which could (if they really need the extra performance) justify the extra challenge and code complexity.
Re: Do you even need a database?
#135I suggest every developer write a database from scratch at least once, and use it for something real. Or, even better, let somebody else use it for something real. Then you will know "why database".
There are also things besides databases that I'll DIY and then still wonder why so many people use a premade tool for it, like log4j
Re: Do you even need a database?
#136But if you have data that is static or effectively static (data that is updated occasionally or batched), then serving via custom file handling can have its place.
If the records are fixed width and sorted on the key value, then it becomes trivial to do a binary search on the mmapped file. It's about as lightweight as could be asked for.
Re: Do you even need a database?
#137At some point, don't you just end up making a low-quality, poorly-tested reinvention of SQLite by doing this and adding features?
Reminds me of the infamous Robert Virding quote: “Virding's First Rule of Programming: Any sufficiently complicated concurrent program in another language contains an ad hoc informally-specified bug-ridden slow implementation of half of Erlang.”
Re: Do you even need a database?
#138You'll likely end up quite a chump if you follow this logic.
sqlite has pretty strong durability and consistency mechanism that their toy disk binary search doesn't have.
(And it is just a toy. It waves away the maintenance of the index, for god's sake, which is almost the entire issue with indexes!)
Typically, people need to change things over time as well, without losing all their data, so backwards compatibility and other aspects of flexibility that sqlite has are likely to matter too.
I think once you move beyond a single file read/written atomically, you might as well go straight to sqlite (or other db) rather than write your own really crappy db.