Giving up on MongoDB

Dec 27, 2017

Part of quitting Twitter necessitate rebuilding Grumpy Gamer. The Thimbleweed Park dev blog was based on the Grumpy Gamer blog code, but I'd made a lot of improvements that I loathed losing, but even the Thimbleweed Park blog code was starting to feel old and worn.

It was time to start over, and by start over, I mean completely start over. I crave change. When I find myself in a rut, or lacking motivation, I strive to change as much as I can to spark my imagination.

Writing a new blogging platform from the ground up (again) was what I needed. It's not rocket science, which is exactly what I needed.

My first decision was what to do about the database. The old-old Grumpy Gamer blog used MySQL, but when I rebuilt that into the old Grumpy Gamer blog I became fascinated with MongoDB. I'd worked a lot in a structured database, and the unstructured nature of MongoDB was enticing. Need a new data column? Just write to one.

MySQL was feeling very heavy, MongoDB felt light and fast.

Three years later, I am back to MySQL and I can arbute that to two things:

  1. The lack of a web based tool to quickly manage and query the DB. There are web based tools, but none of them (that I found) can display your data in anything that resembles a table to quick scanning and editing. Any time I needed to "massage" the DB outside the blogging admin tools, I dreaded it.

  2. The MongoDB query language is a mess. You're basically constructing JSON/Javascript queries and it just reeks of being wedged into that format. SQL might not be much better, but at least I know it well.

After a few years with MongoDB, I'm also realizing that I was incorrect in one of my initial assumptions: MongoDB is no faster than MongoDB and the footprint on the server is about the same.

I'm sure MongoDB is better for certain tasks, and MySQL for others, but it largely comes down to what you know and what your comfortable with. For me, that was SQL.

P.S. I don't like that MySQL is owned by Oracle, but I'm not sure I want to make the jump into PostgreSQL. Maybe the next time I'm feeling bored and unmotivated.

Dan Dec 28, 2017
Can't you use mariadb to avoid Oracle?

Ron Gilbert Dec 28, 2017
Interesting... I'll check it out when I have some free time. I need to get back to the swearing clown DLC.

Federico Dec 28, 2017
I think you mean that MongoDB is no faster than MySQL? The speed depends heavily on the usage you give to the DB. If you use a NoSQL and you want to do queries like an structured DB the performance will be astonishingly bad.

Andrew Herron Dec 28, 2017
This might be a bigger change than you wanted, but do you even need a database? There are plenty of static site generators for blogging now that save _all_ of that hassle :)

Ron Gilbert Dec 28, 2017
The First iteration used no DB, it was all done with flat files. Comments became an issue.  Again, I'm not trying to solve a problem, the problem is already solved. MySQL works great for this and my traffic is so low it doesn't really matter. I could have done static html generation, but this was easier for me.

Nor Treblig Dec 28, 2017
I also wonder why you haven't switched to MariaDB (, I'm not a big Oracle fan either.

Please include the actual timestamp of comments, at least as data.

Björn Tantau Dec 28, 2017
On most newer Linux distributions you usually get MariaDB anyway if you try to install MySQL.

Per Dec 28, 2017
MySQL/MariaDB is a fine choice for a simple blogging backend or systems that only use the database as dumb storage for persisting data that is fully handled by external application code. Once you start storing lots of relational data and want to really take advantage of the power of SQL to write advanced reports, or you need fine-grained high read/write concurrency, there is no (Open Source) alternative to PostgreSQL.

Valdir Dec 28, 2017
There is almost no fun in the db world. Only work.
An open source alternative to PostgreSQL is FirebirdSQL. Small footprint, plus the database data live in one single file.

Per Dec 28, 2017
FirebirdSQL 3 is a great alternative for embedded or "bundled" databases but I would not consider it for a production backend database, for no other reason that I can't think of anything important that it would do better than PostgreSQL and it is not nearly as tested and it's lacking 3rd party support. However, starting with MySQL v8 (currently beta) and MariaDB v10.2, those databases are finally becoming pretty darn competent and PostgreSQL will have to watch out. PostgreSQL development has a very fast pace and is still accelerating so the lead is still significant in most (but not all) areas, but MySQL and its forks are catching up.

Gustavo Dec 28, 2017
As a database professor, I found this post very interesting. Thank you for sharing your experience!

Artyom Dec 28, 2017
You can use MariaDB to avoid Oracle -- and you don't need to learn anything new to use it.

Or you can make the jump to Postgres. I totally recommend it. Basic stuff is the same really, and once you get into advanced stuff you'll see Postgres is just at a different level.

Ron Gilbert Dec 28, 2017
Never heard of MariaDB before. I'll switch it in when I get a chance.

Ron Gilbert Dec 28, 2017
Please include the actual timestamp of comments, at least as data.

The full timestamp is in the DB, but I see no reason to display it. I quite like relative dates.

Nor Treblig Dec 28, 2017
Relative dates suck. If you look at an already open page you never know from when those posts are. If you look at a screenshot you don't know from when those are.
In one year they all say 1y, 1y, 1y, 1y although there may be weeks in between.

Relative dates are OK if they are here ADDITIONALLY. If you add the timestamp just as an HTML attribute it would be enough so I can display them however I want.

Ron Gilbert Dec 28, 2017
Fine. I added a nortreblig= tag to the dates. Go crazy.

Ron Gilbert Dec 28, 2017
But for the record, viewing this website without relative dates on the comments isn't canon.

Nor Treblig Dec 28, 2017

Zak Phoenix McKracken Dec 29, 2017
MariaDB it's exactly MySQL, because it's made by the same guy (Michael Widenius), who decided to create a new free of use DB, when Oracle acquired Sun Microsystem.

Bruce Heller Dec 31, 2017
The only drawback of using mysql or Mariadb is when you need to replicate data among servers. It's just a nightmare! That's where solutions such as elasticsearch can make a great change.
Otherwise, go for the sql way of life!

Ron Gilbert Dec 31, 2017
Yeah, I don't think the Grumpy Gamer blog will need large scale replication across load balanced servers. 😀

Thomas Jan 03, 2018
In your case I recommend MariaDB over MySQL. Because of Oracle, nobody knows if MySQL remains free and Open Source in future.

Joe Jan 07, 2018
I know the issue has been beaten to death already, but one thing that hasn't really been pointed out is that MariaDB is a *drop-in* replacement for MySQL. That means you can switch the binaries over and I think you only have to run the MySQL db upgrade thing. All the binaries have the same name (so daemons etc are still called mysqld).

Joe Jan 07, 2018
Okay I just tried "dropping in" mariadb on an Ubuntu 16.04 production server and had a hard time. Ubuntu have done some freaky stuff to those packages. Maybe don't do it right now.

Yam Aug 29, 2018
What about MongoDB compass and Robo3T. You can view your data as tables and edit them.

k00x Jan 16, 2022
I just built a new blog using Django, its an absolute pleasure to use. It's well supported with Postgres, which is ideal for people who like to frolic on the command line as I do. There is no doubt that I will return to mySQL as I suffer from a medley of loyalty to old tech, fear of new things, and a mild form of programmers Stockholm syndrome. But if I wasn't an old dog that forgets new tricks easily, I would stick with postgres!