Highly Opinionated Thoughts on Programming

by Elnur Abdurrakhimov


Avoid MySQL

Mar 30, 2014


MySQL sucks. It’s dangerous. MySQL has nothing you can’t find in other databases. Alternatives exist and are of much higher quality.

My last straw with MySQL was this bug and I’ve switched from MySQL to PostgreSQL the same day I’ve encountered it. It happened 5-6 years ago and I never looked back. And that bug haven’t been fixed yet.

It’s not really important what the bug is, it’s the mentality of MySQL developers to do buggy shit they can’t fix and then call them features.

I won’t go into technical details in this post, because there are already a lot of people telling why you should avoid MySQL. I’m just trying to reinforce what others have already said and add some of my own disdain for MySQL. If you need the details, you can find them here:

When you ask the javabot on the ##java channel on irc.freenode.net, it will tell you what it thinks about MySQL:

<elnur> ~mysql
<javabot> elnur, mysql is a network-attached spreadsheet used by pr0n sites and other dodgy entities across the Internet.  You can learn more about it at http://www.mysql.com - free download of the open-source version, including JDBC drivers. Also: http://grimoire.ca/mysql/choose-something-else

Compare this with what it has to say about PostgreSQL:

<elnur> ~postgresql
<javabot> elnur, postgresql is a highly scalable, SQL compliant, open source object-relational database management system. See http://www.postgresql.org/ and http://jdbc.postgresql.org/ for the jdbc driver.

Or MongoDB:

<elnur> ~mongodb
<javabot> elnur, mongodb is a cross-platform document-oriented database system that uses JSON-like documents with dynamic schemas.  See http://mongodb.org for more information.

As you can see, MySQL is the only one disrespected.

If you google with an open mind, you’ll find much more people bashing MySQL for good reasons. You will also find people writing about MySQL superiority to PostgreSQL, but they don’t have a clue what they write about. For example, see MySQL vs PostgreSQL: Why MySQL Is Superior To PostgreSQL and after reading the post, be sure to read the comments too.

There’s plenty of information why you should not use MySQL, but it still seems like 99% of new projects go with MySQL. I’ve personally convinced some people to switch to PostgreSQL and they’re happy they did, but it’s still a drop in the ocean. I would like to see a mass exodus from MySQL. That would give me some faith in humanity.

I have nothing against MySQL per se as long as it doesn’t affect me. If you’re masochistic, keep using it — I’m happy for you. I’m just really tired of inheriting MySQL projects. I migrate them to PostgreSQL as soon as I can, but sometimes I have to endure MySQL for months and it drives me crazy. It’s especially crazy when people enforcing the usage of MySQL are the ones who still mix HTML, CSS, JavaScript, and PHP in a single file.

There’s just no place for MySQL. If you need an RDBMS and rely on the database to be kinda smart and prevent invalid data from creeping in, there’s PostgreSQL; MySQL sucks at this anyway. If you use MySQL as a dumb storage engine without constraints and foreign keys (yea, MyISAM, I’m looking at you), then you could just as well use MongoDB or other NoSQL solutions for that.

Yes, there are lots of websites that use MySQL and still do good. You could make your website look great on IE6 too, but it was painful and required the same amount of work — if not more — as was needed to make your site look great in all other browsers combined. Just because you can make it behave doesn’t mean you need to waste resources on that. With IE6 we had no choice, since it had a huge market share back then, but we do have a choice on what to use on the backend.

I don’t know why MySQL got so popular in the first place. Maybe it was because PostgreSQL developers didn’t give a damn about Windows users for a long time; I still don’t, BTW. Or maybe the reason was that a lot of shared hosters were providing MySQL only. Or maybe it was marketing and then the popular LAMP stack that assumes MySQL as the database. Whatever the reasons, MySQL became popular not for technical reasons. If you think that popularity means that something is good, remember IE that was very bad back in the days and had more than 90% of market share anyway.

And if you think that the fact that Oracle bought MySQL and not PostgreSQL tells something good about MySQL, you’re wrong. It’s just impossible to buy PostgreSQL. If it was possible, I have no doubt that Oracle would buy it instead. And if you wonder why it’s not possible to buy it, you should know that MySQL is an open source product, while PostgreSQL is an open source project.

I despise MySQL so much, I turn down job opportunities that insist on keeping using MySQL even after I tell them how dangerous it is. I do that not because they use MySQL now for whatever reasons, but because they have no plans on migrating to something else. If they love their MySQL and don’t want to let it go, I wish them good luck and move on.

If you’re one of those developers that have never tried PostgreSQL for at least a couple of weeks or just heard a lot of BS about it, don’t even try defending MySQL. Just give PostgreSQL a try with an open mind. You can thank me later.



© Elnur Abdurrakhimov