The article is fine, but I wanted to call this out. "Every database you have ever used reads and writes to the filesystem, exactly like your code does when it calls open()." Technically not true. Applications like SQLite use mmap to map the file into a locally addressable memory space. This lets you skip the syscalls when reading and writing. The kernel can map that data in dynamically much faster than a userland pro…
Do you even need a database?
241–250 of 311 posts
Re: Do you even need a database?
#242Earlier quoted context omitted.
As soon as you need to do a JOIN, you're either rewriting a database or replatforming on Sqlite.
a) Just heard today: JOINs are bad for performance b) How many columns can (an Excel) table have: no need for JOINs
Re: Do you even need a database?
#243Earlier quoted context omitted.
“You Aren’t Gonna Need It” - one of the most important software principles. Wait until you actually need it.
100%. Premature optimisation I believe that's called. I've seen it play out many times in engineering over the years.
You are just mislabling good architecture as 'premature optimization'. So I will give you another platitude... "There is nothing so permanent as a temporary software solution"
Re: Do you even need a database?
#244Re: Do you even need a database?
#245Earlier quoted context omitted.
For the simple case, it isn't necessarily that fragile. Write the entire database to a temp file, then after flushing, move the temp file to overwrite the old file. All Unix filesystems will ensure the move operation is atomic. Lots of "we dump a bunch of JSON to the disk" use cases could be much more stable if they just did this. Doesn't scale at all, though - all of the data that needs to be self-consistent needs t…
don't forget to fsync the file before the rename! and you also need to fsync the directory after the rename!
I believe syncing the parent directory is only needed for durability and not atomicity, but if you're using this method you're probably not caring about durability in the first place, because you've designed a system that doesn't let you do durability in a fine-grained way without severe performance loss.
Re: Do you even need a database?
#246Earlier quoted context omitted.
https://docs.oracle.com/cd/B16276_01/doc/win.102/b14305/arch...
> Oracle® Database Platform Guide 10g Release 2 (10.2) for Microsoft Windows Itanium (64-Bit) Well, I guess that at least confirms Oracle on Itanium (!?) still supported RAW 5 years ago. I'm guessing everyone's on ASM by now though, if they're still upgrading. I ran into a company not long ago with a huge oracle cluster that still employed physical database admins and logical database admins as separate roles...I wou…
I seem to remember Oracle 10g was first released over 20 years ago? It has been EOL for much longer than 5 years...
Re: Do you even need a database?
#247This is a great incredibly well written piece. Nice work showing under the hood build up of how a db works. It makes you think.
Re: Do you even need a database?
#248You need databases if you need any kind of atomicity. Doing atomic writes is extremely fragile if you are just on top of the filesystem. This is also why many databases have persistence issues and can easily corrupt on-disk data on crash. Rocksdb on windows is a very simple example a couple years back. It was regularly having corruption issues when doing development with it.
Re: Do you even need a database?
#249I sympathize with this so hard. I frequently conduct system design interviews where the problem could easily be handled on a single machine with a flat file, let alone sql lite. Only the rare candidate mentions this; mostly I get a horde of microservices and queues and massive distributed databases that are totally unneccessary.
From that POV I moved from the extreme of "you don't need a state at all (and hence no database)" to the bit more moderate "you usually don't need a file or a DB but you almost certainly will want to query whatever state you store so just get a DB early".
I strongly sympathize with "no microservices" of course. That's an overkill for at least 99% of all projects I've ever seen (was a contractor for a long time). But state + querying is an emergent property as a lot of projects move beyond the prototype phase.
Re: Do you even need a database?
#250Earlier quoted context omitted.
It isnt sarcasm. I don't really find a case that a database that has it's own query language like SQL is needed. It won't be different than storing a JSON file and filter the content with a for loop, the dev (e.g. me) will be returning a JSON on REST API at the end. A query language may be a good thing if you are working in a team, thats it. SQL is indeed isnt a good thing.
Um, so your use cases are extremely narrow and limited. That's an astonising failure of imagination and a lack of understanding of real-world computer systems if you cannot understand why people have a real need of both the power of SQL and the performance of RDBMSs.