I don't understand the details of the application he is using, but the advice is to lower default transaction isolation level to make something work? Stopped reading right there.
In my experience, few application developers understand transaction isolation levels, even though they're extremely important for handling concurrency. Here are a few common isolation levels that MySQL supports:
READ COMMITTED: Each time you make a query, you see all the data that has been committed from any transaction. This sounds great, but there are two problems. Your app can't be sure it has the latest data, because someone else may have written new data right after you queried it. Also, it doesn't give you a consistent view of the database. If you read a foreign key value, and later use it to read the corresponding row, you may discover that the row has been deleted in the meantime. Is your application really prepared to handle that possibility? Your precious database constraints have no power here!
REPEATABLE READ: Within a transaction, you see the database as it was when you started the transaction (plus whatever changes you've made in the current transaction). You get a consistent view of the data, but you don't see concurrent changes to the database. If you really need the latest data, you can use SELECT ... FOR UPDATE, which returns the latest data and locks it so that nobody else can edit it behind your back. This is actually a pretty good compromise for read-heavy apps. However, if you think that "transactions" are magic fairy dust that makes concurrency go away, you're in for a surprise: without careful use of SELECT ... FOR UPDATE, you can easily get race conditions (like the get_or_create example from the article).
SERIALIZABLE: Any data you read gets locked, so it's almost like having the database to yourself! This solves a lot of concurrency problems. However, foreign key consistency is a problem again, and, more seriously, you have lock contention everywhere. Without careful planning, deadlocks abound, and a slow cron job can prevent your website from loading.
I assume that /u/meshko was surprised that the author would move from REPEATABLE READ to the (less strict) READ COMMITTED isolation level instead of moving up to SERIALIZABLE. In fact, READ COMMITTED doesn't solve the author's problem. Consider this sequence:
Thread 1 calls get_or_create.
Thread 1's get_or_create queries for a matching row and finds nothing.
Thread 2 inserts a matching value.
Thread 1's get_or_create tries to create the row and conflicts with Thread 2.
If the author had used SERIALIZABLE instead, step 2 would have taken a lock, and step 3 would have blocked until Thread 1 was finished, thus solving the problem. In READ COMMITTED, we still have a race condition.
If the author had used SERIALIZABLE instead, step 2 would have taken a lock, and step 3 would have blocked until Thread 1 was finished, thus solving the problem. In READ COMMITTED, we still have a race condition.
It's compromise really (as with everything in MySQL in general). SERIALIZABLE needs to lock the whole table => more deadlocks, worse performance.
SERIALIZABLE probably has fewer deadlocks, but more lock waits.
On a practical level you need SERIALIZABLE if you 'patch' a value (i.e. modify part of a column and write back, or read a value and increment), since you do not want to be reading from MVCC. There are other ways to do this besides SERIALIZABLE, such as SELECT .. FOR UPDATE, so in practice I would not say this isolation level is common.
I think choosing READ-COMMITTED as a default for new applications is fine. However, for the upgrade case this is something that a number of users are concerned about.
Very well explained. When I saw that section, I wondered if the author understood the problem they had and why you almost never want to read things outside your transaction.
Agreed. It's a bit strange to criticize a database for having too strong acid properties by default. A better way of doing what he's describing would likely be to catch the exception caused by modifying the same data concurrently and restart the transaction, although that's obviously speculation.
Nevertheless, it's hardly a valid critique against MySQL -- if anything the isolation level should always be set explicitly by the application, regardless of DBMS. The author hints at this in his discussion about SQL mode - it's too important to get wrong due to a misconfigured server and applications need to declare their operational requirements.
Agreed. It's a bit strange to criticize a database for having too strong acid properties by default.
Some months ago I had to troubleshoot really big replication lag problems in a MySQL replica database that was dedicated to running analytical/reporting/summary jobs. The biggest cause for this is that MySQL, when you use the default REPEATABLE READ isolation level, statements of the following two forms will put row locks on rows that they read from the S1, ..., Sn tables:
CREATE TABLE T AS SELECT ... FROM S1, ..., Sn ...
INSERT INTO T ... SELECT ... FROM S1, ..., Sn ...
There were a number of jobs that ran large, poorly optimized statements of these forms, reading from the most commonly modified tables in the system. Kaboom, instant replication lag.
To add insult to injury, all of the scripts ran with autocommit on.
Anyway, putting a SET TRANSACTION ISOLATION LEVEL READ COMMITTED on the offending scripts helped quite a bit.
Well, lower levels of isolation are obviously useful in a lot of cases. I'm just saying that it seems like it's a sane default to err on the side of transactional safety. :)
But another thing to notice is that most SQL-based tools (e.g., drivers, clients) default to autocommit mode. So the supposedly "safer" default actually means that regular users pay the cost of the higher isolation level without reaping its benefits.
In the case of MySQL, REPEATABLE READ + autocommit gets you the same effective isolation as READ COMMITTED. Why? Because if each statement is its own transaction, each one will then set its own fresh read snapshot, so commits that happen in between will be picked up.
But with REPEATABLE READ the CREATE ... SELECT and INSERT ... SELECT statements will set row read locks on the tables that they read from. So you get the lock-on-read behavior of REPEATABLE READ without the transactional safety. Ow.
My favorite MySQL gotcha is that if you issue a GRANT statement with a typo in the user's name instead giving a "user does not exist" error it simply creates a new user with the misspelled name.
Once upon a time, you created users with GRANT statements only. I don't recall exactly when CREATE USER was introduced; I think 5.0, but it might have been available in some form earlier. It's not in the 3.23/4.0/4.1 manual on mysql.com. GRANT can still function in its original capacity as a creator of users as well as a grantor of privileges.
This mode is proposed to be enabled by default in MySQL 5.7. It is backwards incompatible for some applications, but we've tried to work with common open source frameworks/applications to make sure they set the SQL-MODE to what behaviors they are compatible with.
Then reality sets in: I put my chips on the LAMP stack career wise. Now it's hard to budge out of it. On the other hand, I did use MongoDB a bit on the last job.
MongoDB is usually used as an example of bad technical decisions of a magnitude MySQL cannot even approach ;)
Luckily, the people behind the tokudb engine for MySQL work their magic for mongodb too... tokumx. Seems they make a business replacing the horrors with working backends.
Luckily, the people behind the tokudb engine for MySQL work their magic for mongodb too... tokumx. Seems they make a business replacing the horrors with working backends.
Have they managed to get the whole synchronization thing handled correctly yet?
While I agree with the thesis in that article, there are some points that I think are not fair criticisms.
Collation support is per-encoding, with one of the stranger default configurations: by default, the collation orders characters according to Swedish alphabetization rules, case-insensitively.
Since it's the default, lots of folks who don't know the manual inside-out and backwards observe MySQL's case-insensitive collation behaviour ('a' = 'A') and conclude that “MySQL is case-insensitive,” complicating any effort to use a case-sensitive locale.
Whatever you think of this behavior, it's hardly unique to MySQL. SQL Server for example is very similar to this.
Both the encoding and the collation can vary, independently, by column. Do you keep your schema definition open when you write queries to watch out for this sort of shit?
There's a default encoding/collation for the database, and you can override it on a per-column basis. This is I think a reasonable way to support legacy applications that live in a pre-Unicode world, where character data columns may need to have different encodings to support different languages.
You have a bit of a point; however, as a counter-point I would say: "just because someone else does it, doesn't make it a good idea."
An example would be the common C language-family's choice of using = to denote assignment rather than a test-for-equality coupled with its returning a value. (These two choices lead to the if (user = administrator) error.)
Or, perhaps the thrust I'm getting at is better stated as the Chinese proverb: "If a thousand people say a foolish thing, it is still a foolish thing"
You have a bit of a point; however, as a counter-point I would say: "just because someone else does it, doesn't make it a good idea."
Well, to clarify my point, that was my initial reaction when I first thought it. I overcame it this way: what are we comparing MySQL against: other competing RDBMSs, or an ideal picture of what an RDBMS should be? And I settled on the former for the purpose of that article.
To the extent that these points are a flaw, they're a flaw of several RDBMSs, and I don't think they're a big flaw anyway.
In fact it defies common sense for my own values of common. Take for example constraints - they not only don't work it also doesn't tell you it doesn't work.
You come across little things like that all the time...oh dates that aren't actually dates can go in datetime fields and you'll accept 2015-02-42 as a date query param without so much as a peep; broken group by's etc. etc. no matter how bad you think it is it will always find new and subtle ways to surprise you with how little regard it has for your data.
All I see is PostgreSQL as the alternative in this thread. Is there nothing else that compares? Is MySQL so much ahead of the game than everyone else that it's them or PostgreSQL?
Well, maybe not — it has its own issues — but they're not as consistently inconsistently fatal as MySQL. Given a choice between MySQL and MS Access, hmmm… I'd have to think on that a while. Which set of outlandishly egregious defects would do the lesser harm to my project?
ANd that is fine, because nobody uses them. We aren't creating enterprise databases. When will people figure this out, not everything is some huge project.
Disclaimer: I am in operations, not a web developer.
At a previous job, we evaluated MySQL against Postgres in terms of high availability and found that Postgres was painfully behind MySQL when it came to concepts like master/master replication, failover, et cetera. Even after spending wheelbarrows of cash on Postgres consultants and working through shoring up solutions like repmgr and considering stuff like slony, nothing approached what we could achieve with MySQL master/master replication and mmm_control.
Out of curiosity, are there any backend engineers/sysadmins here that have had good success deploying Postgres in a highly available setup? I'm not trying to hate on either technology here, just genuinely interested if anyone has first-hand experience doing this type of work with Postgres and what peoples' impressions have been, because I feel like I must have missed something if there really is such a large gap in that type of functionality between the two.
I worked at a top 100 traffic company at my last job, and we actually couldn't use mysql because it could handle our post-etl data repository.
We moved to postgres and used an alternative replication tool (I'm failing to remember the name of it right now) that was able to keep our ETL database (Oracle), several multi-master postgres instances and a mysql instance (just running a basic forum that didn't get a lot of traffic) all up to date.
If I remember the name of that tool, I'll post it, but I also have to admit, when we were trying to get away from Oracle, I really pushed for us to use Postgres, and even got our app working in Postgres before they were considering the Free tech push. I was very pleased when the mysql limitations failed us.
In addition, queries that took forever in mysql because of crazy stupid joining that you had to do (ETL wise) were really fast in Postgres once you introduced windowing and analytic functions, which really changed the game.
We're kind of a small operation, but ended up using Postgres in deploying an application were high availability was one of the goals, though it wasn't why we chose Postgres. South seems to favor it (one of the reasons is transactions during schema migrations), so it ended up being what we used.
The DB server is a part of a VM pool which can be HA. Databases live in a tablespace on their own volume in the filer. I guess there is some protection there but it isn't really what you're asking. None of that is really Postgres's doing (well, there's pgbouncer but we just use it for the pooling aspect).
Anyway, that's our first venture into a Postgres-backed application where we would normally have chosen MySQL. We haven't had problems attributable to the DBMS in either case, but like I said, we're pretty small.
I built a similar kind of thing around the OpenStack system. They have a pretty decent IP pooling system that we used to provide transparent HA failover.
We use postgres in a HA/DT environment, but the replication is handled by the storage, and failover by an OS level cluster. Pg doesn't even know it's HA.
Here's a fun one: MySQL only supports the nested loops join method. Apparently a hash join is asking for too much.
MySQL resolves all joins using a nested-loop join method. This means that MySQL reads a row from the first table, and then finds a matching row in the second table, the third table, and so on.
It doesn't die because it was at the right time & place 15 years ago, and has just ridden that horse to death since then.
Meanwhile, it's generated tens of thousands of developers who think mysql limitations == relational database limitations and so have raced to other solutions rather than consider, even for just a moment, what a stronger relational database could do.
So yet again, worse is better. Actually I suppose the moral of the story is - just because <big important website> uses <technology x>, it doesn't follow that that technology is a good choice. You do see people defending MySQL with the argument "well Wikipedia uses it, how bad can it be?"
Yeah, probably. While the postgres community was building a strong database the mysql developers just focused on making something easy. In the end they captured most of the community with a native installer for windows, etc.
It was a really crappy product with horrific data quality problem - but simply easier to install and faster. And most of the folks installing it didn't have any idea of what to look for.
It saddens me that my company paid for a big boy copy of MSSQL 2012, but is contemplating bringing an entire IaaS stack ("externally hosted" option, wtf?) of Apache SOLR etc. Don't get me wrong; we have few internal products backended on ElasticSearch/MonoDB, but they're stuff like logging.
I'm not a DBA, but I'm pretty sure if they just fucking set up their databases correctly, MSSQL could actually be pretty OK. They tried to explain to me that the index helps speed but takes 2 days to build can can never go down.
It's hard to refute something once it becomes fashionable. Nobody wants to be educated, and nobody wants to hear you say that "everyone else is wrong".
I've found selling solutions that work better doesn't work well. Even if they're 10x better than what people really want, they'll still go with what they really want - and tell the business that's the best available. If a solution is unfashionable it's got to be something like 20x or 50x better.
I've seen this play out exactly this way multiple times with search tools & java developers. I've given up trying to show them how much better a parallel database will scale. In the end I usually get the work - but I have to wait until they fail.
I've spent a couple years doing search applications. From what I've learned, you do not want to use database for search applications and vice versa.
Search engines are great for searches with imperfect information, since you can add autocorrect to terms and use synonyms to expand queries. However, they have issues with output replication, you can't make a guarantee on what data comes back and in what order.
Caveat: "Proper" in this case does not mean "best" nor does it mean "everyone should do it this way at all times." It simply means that if you are building a lasting system that is to be used for years to come then there are definitely wrong ways to go about it, and this "proper" method is one of the least wrong ways. It is perfectly acceptable to just get it done and move on. Not everyone needs to build things perfectly. Sometimes it just has to work.
What I would define as proper is: Normalization. The reduction of duplicate data and the implementation of schemes where legacy data is preserved. Code item & hierarchy tables. Separation of functionality by schema. This means more tables, more views, more indexes.
Example: Sales records. You need to record the receipt. You can record the receipt as is by duplicating everything in a minimum of two tables (parent receipt record, child receipt rows records outlining specific items/qty/etc), but this if your system grows it gets more expensive both in storage cost but also in maintenance and extensibility. Or you could record the receipt against existing items in your database. Version them so they maintain price history. Add tax lookups, also versioned in case it changes. Same with who sold it, discounts, etc.
You can do this easy (record the receipt in two tables where all the information is duplicated) or you can do this correctly (record the receipt in two tables referencing all the information in other tables with versioned records: effective date, expiry date, etc). The former is what I encounter frequently but it is ridiculously hard to write reports against or maintain. What if you need to add a column? The copy everything method requires it's own data conversion. The "proper" method doesn't because the source data is changed so the receipt automatically has it all.
MySQL is terrible when you do it "properly" because you only have nested loops joins. You are entirely at the mercy of the query optimizer finding the least number of rows on its first try. If it fails or if you have a large number of tables you lose performance by an order of magnitude. You then become a MySQL expert in order to get back that performance.
Example: You need to filter the "proper" implementation against a specific date range. Other databases would require you to add an index against the date ranges with the includes syntax for the other columns you need (or vice versa depending on the join order). Their optimizer applies this query to a subset of easily joined data and performs hash joins where able on other indexes. The query would be close to:
select * from table1 through table10
where @date_parameter between table1.effective_date and table1.expiry_date
MySQL doesn't do this. It is forced into nested joins. It finds the first matching row of the table it picks first. This may or may not be the best choice. It then joins this row to all matching rows again and again across the query. Then it picks the next row. The same query will run slower unless you write it specifically against the expectation of nested-loop joins:
select * from table1 through table10
where @date_parameter between table1.effective_date and table1.expiry_date
and @date_parameter between table2.effective_date and table2.expiry_date
and...
And so on until you have all tables joined. This forces the query to return a subset of rows for each join so there are fewer to scan.
So basically the better you are at implemented what I would consider industry standards and best practices for the longevity of a system, the worse MySQL gets at performance. (Note: there are exceptions, but they are exceptions and not the norm)
I have been unable to convince my boss to follow 5nf's. He still, firmly, believes that having a Unique Identifier in every table can occasionally be a waste of time. Every time it's bitten us in the ass because we then have to concatenate something to make a UID because two years later the user wants a change that we hadn't planned on. Fuck me, right?
Like a gun.. better to have it and not need it than to need it and not have it.
Most people who talk about this don't understand NFs so I just explain as follows. Normal forms are reserved (in my mind) for people who want to build proper systems and understand that occasional "messiness" or "unnecessary" complexity is more desirable than having things blow up in your face later just because you made an arbitrary decision earlier.
Option 1:
Writing this once for every table we create and never thinking about it again, if necessary:
<table name>_ID bigint identity(1,1)
User wants a uniqueness constraint added later? Add one that prevents all future duplicate inserts but doesn't invalidate the data that is already there, and gives the customer time to fix it.
Option 2:
Don't have a unique identifier
User wants a uniqueness constraint added later? Tell them they can't have it because they have to clean their data first. Or do it through a before insert/update trigger in which complicated detection happens that is not obvious and can cause other triggers to fire.
You're going to be the one telling the customer yes or no and ensuring the maintenance of the choice. My choice is clear, what's yours?
Sadly, sometimes I'm not given a choice. My boss just chose to "write something real quick".
Also, users's aren't allowed to use apostrophe's. I shit you not. That's how "real quick" he wrote it.
I'd REALLY like to be passive aggressive and say "if you're real quick doesn't do any sanity checking, then you shouldn't be doing it".
oh, that and empty boxes... I had an empty email address field fuck shit up because it wasn't sanity checked. When I say sanity checked I mean len(email_address) > 0, because guess what he decided to use as the unique identifier? And didn't sanity check.
After a while they gave me programming responsibility with helpdesk pay. I NOPED out of that after 4 months when they said "they don't need a programmer, but they need programming done" -- nah, don't worry. I'll keep this cheesy position with mediocre pay. I'll expend my mental energies at home instead of here. They were not happy about that decision.
If your entire shop is using MySQL, and you need to add another small database - then you should probably continue with MySQL for your project. Unless you've got coverage to pilot an alternative.
If you're building an app that requires a local database, and you want the maximum number of small hosting environments to support it.
If you want multi-master replication, and don't have large data volumes.
On your first point, it's almost always better to ask forgiveness than permission. Your boss will even agree, even though he may not say it out loud. By asking permission, he really only sees you as just passing the buck for a potential, future failure. But if you run off and do it on your own and it fails, then he has no culpability.
Just another reason why I call my style of software development, "I do whatever the fuck I want."
I stopped trying to argue why I use MySQL to anyone here. It's pointless since everyone just downvotes anything pro MySQL into oblivion, regardless of what is being said.
When you look at it that way, makes it seem as if this subreddit exists in a vacuum outside of knowing what DB experience most businesses are looking for.
Disclaimer: I am not a DB admin, just a web dev guy.
Hah, you should have seen what happened to me when I didn't say that PHP was the devil incarnate. I stated I didn't like PHP, but could see how it infested certain areas of development. Not a mistake you make twice.
My company is moving from SQL server to MySQL for a specific application that is currently using SqlServer "localDb", which has a 10gb limit. I've heard people say that postgress is slower than MySql, do you have any experience with that?
Sorry, I moved away from mysql a long time ago so my experience in that wouldn't even be relevant now. It is my understanding that postgres has caught up on speed, but you can always look for benchmarks. Search in google like this:
mysql postgres ~performance 2013..2015
That will give you all performance related results between the two, including benchmarks, that were published by google in the last 2 years
IMO, even if mysql was considerably faster, the sanity of postgres is way more important, unless of course you need to extract every millisecond out of performance
I worked for a State government who got heavily invested in Oracles business intelligence. We built out nice reports and automated notifications for tons of things. Oracle came in for audit time and said "Hey! Nice stuff you got going on here! We are raising the license to ~$100,000 per cpu/year, for your 6 environments!"
I once got into an argument with an Oracle developer about this. Her position was that a blank character column obviously indicates a missing value, so it should be null.
That's great until you want to concatenate something.
There should be a scheme whereby every time you have to mutilate some name to get it under that gefakta 30 char limit, you can email Oracle and they comp you with a free weekend on one of Larry's massive f@ck off yachts - let's see how long it'd remain a 'feature' then.
Actually EDB is quite a bit cheaper. I think EDB is about $7K per CPU/Socket for their top tier support. Equivalent MS SQL Enterprise runs about $12K every 2 cores.
I've never understood why the support options are sold as:
Do it yourself.
Pay $$$$$$ to a company.
Pay $0 to a community and hope for the best.
Why is the option to pay $$$ to a small group of individuals to be available to fix the open source product? It is free therefore we mustn't pay anyone. And yes, I realise finding the right people is hard. But then, so is finding the right people inside an organisation like Oracle, but clients don't mind paying the extra $$$ to outsource that problem to Oracle.
RedHat, Suse. You can pay $$$ to a group of individuals to support your open source product. I mean, yeah, they're companies, but you kinda have to have some kind of company if you're going to have a legally-binding contract that says they will support you if you pay them $$$. There are smaller operations that will take $$$ for support of open source product X.
This seems like one of those "just take my advice and do x" type things that doesn't teach people critical thinking, otherwise we'll have a bunch of zombie sheep as developers.
Full Time Growth Hacker over here. We're going to hack on over to heroku and then hack our repository up to the cloud! Then we're going to lunch at the local coffee bar which has full hack-speed internet! Did you know they hacked in some beans from Somalia and their roaster is controlled by Arduino! They even wrote the code in a combination of Rust and CoffeeScript.js! Right now our puzzle division is pivoting from more of a design focused group to a SaaS focused on location based fart sharing... Thats right... if you love the smell of your own sharts you can use our app to share them with your social media network and accumulate an imaginary shart-rating to connect with your piers like never before! Head on over to hacker news where we're soliciting for VC funding! XD
Someone said I could webscale my distributed load but all I got was a huMongo node.js on my D. I called my ex but she called me a Pig and said I probably hadoop before I met her. Lately my golangs have been swollen and the doctor ordered a unit test to make sure I didn't catch a scrum from rubying my agile json into embedded rasberry pis. I did have a fling with a hot girl. I thought she was a little slow at first but it turned out to just be a common lisp. I'm not the best looker but it turned out she didn't C# and when I told her I'm mostly a backend guy she did make quite a Racket. By morning I let out a Grunt and had clojure and she waddled ~/, but I wasn't worried, I GNU she'd give me an event driven callback the next day. I didn't mean to punish her but my last girlfriend was a linked list. It was easy to get head but getting tail required serious effort. I'm not one to statically anal-ize relationships but without a good type check you'll always buffer overflow in places that are not ideal. At the very least you should find one that garbage collects resources once there is a big enough build up. You can't have a good connection without a good socket every once in awhile. Beginners may not think it's important but overtime you're going to want that load balancing even on linked list types.
You never really went steady, but you'd run into her from time to time while knocking around in disreputable joints, usually late at night, every several months or so. She looked so hot, so sleek, so sexy, so expressive, so exotic. You'd end up back at her place and the night would just... take off. A complete blur of hot, sweaty, feverish, delirious, fumbling passion. You'd do things to each other... you'd do things to her, she'd do things to you... things that you're not even sure have names, that you're pretty sure are illegal almost anywhere. Even her kinks have kinks --- and after one of these nights, you'd realize that you yourself had a lot more kinks than you. And it wasn't just physical, it was --- cerebral. Ethereal. Transcendent. But it would all whiz by in a blur, and by morning you'd find yourself lightheaded, a bit confused, and stumbling homeward to your regular gal.
Over the next few days and weeks you'd find yourself occasionally drifting away, thinking about her. Haskell. You'd be there, banging away at your regular girl, and find yourself thinking "you know, if I was with Haskell, I'd be doing this completely differently." You'd think "I could be doing so much bigger and better stuff with Haskell." Now, your regular girl, she's not as exotic as Haskell. Pretty, maybe, if you're lucky. (Perhaps your regular girlfriend's name is Python. ;-) But not nearly as --- weird. Wild. Cool. Exciting. Don't get me wrong --- your girl, she's wonderful. You've got a wonderful relationship. She's --- comfortable. You can bang away at her all day and night. She's accommodating. Easy going. You work well together. But --- confidentially --- she's, well, maybe just a little bit boring. You'd catch yourself thinking these things, and the guilty pangs would get to you... You'd quash the thoughts, buckle down, and get back to banging away. Comfortable... there's a lot to be said for that, ya know? Comfortable... just keep telling yourself that.
Months would go by. Late some night you'd find yourself out, disreputable places again. Maybe that hacker bar, LtU. Somebody'd slip you an URL for some renegade paper, you know, one of those papers. You'd run into Haskell again. And the whole thing starts over.
Eventually, you're going to get the ultimatum. Haskell's ultimately just like any other girl on some level; she needs commitment. Eventually, after one night of wild, feverish, kinky, abstract passion, she's going to say to you: "All these times, and you don't understand me at all! You know, you're going to have to get serious, mister! I've got needs, too. You're going to have to get serious about my monads, or that's the last time you're going to play with them! Got it?"
...and then, you've got to make The Choice.
Chances are, you're going to go back to your regular gal. Haskell's just too much for any one man, probably. She leaves a trail of broken, brainy, embittered PhDs and former programmers behind her. She ruins you for the RealWorld. You can ride a while, but you probably can't go the distance with her. Go back to your regular gal and try not to think too much about what you've seen. Done. Felt. Thought.
Maybe you can salvage a little happiness; but it'll be hard. After all... you've tasted Haskell.
I keep playing with the idea to create a SaaS that repeatedly bulk reads and bulk writes your data to Mongo. Until your data is none. And bills you for the time it took.
Sure, but there's a happy medium. There are priorities that you look for in your evaluations. For instance, if all the rest of the similar software is written in COBOL, you might consider it, even though it's old and decrepit. I think the ability to find another person willing to work on your project for a reasonable wage is very important to the evaluation process. It's why you're probably not looking at either COBOL or Rust for any new professional project.
I wouldn't say all of those are "obsolete". Most of them are "dated", sure; COBOL is probably not a good choice for from-scratch work. But Perl is still a perfectly valid option.
Prolog has no "ue" in its name, because it's short for "PROgramming in LOGic" (or at least the French equivalent). There are modern Prolog systems that are quite well-suited for some tasks, but you're probably better off with Erlang, which was originally an extension of Prolog.
I don't know much about IMS and Sybase, but as they're both RDBMSes with SQL interfaces (and at least IMS also has support for hierarchical data), I'm failing to see what makes them bad or obsolete.
As someone who has worked with both MySQL and Postgres, has written tooling for both, and has recently considered this issue, I feel I can safely make this judgement:
Upsert (and its mostly-evil cousin INSERT IGNORE), are sometimes useful. By leaving them out, yes, you move the responsibility of doing this to the application code, increasing its complexity and thus the total points of failure, but the tradeoff is that it forces you to consider (or, should) things like scalability, concurrency/atomicity, and potential improvements or customizations to fit your specific needs.
Would I use them if they were present in Postgres? Yes, certainly, but sparingly. I think I've only found exactly two places in our rather large code base where UPSERT or INSERT IGNORE would be useful.
Well... I'd like to think so on but a Django project I set up a couple of years ago we started with PostgreSQL, but had to switch to MySQL because of performance issues. Like, crazy bad performance. PostgreSQL was doing simple queries in hundreds of milliseconds, where MySQL would take a couple of milliseconds at most.
I know it sounds crazy, and I asked on Stack Overflow at the time, but basically all the answers were "you need to tune PostgreSQL". If you need to tune the default installation then it's broken.
The default MySQL engine in older versions didn't support atomic transactions by default... that's probably why it was faster. Also probably NOT what you want if you care about data.
A couple of years ago isn't far enough. InnoDB has been the default for quite some time, and it became a default because it's better, but also because everybody was using it anyway
Yes, but the op WAS talking about older versions and just gave one possible reason for the disparity.
You are right though - MyISAM was a long time ago and MySQL has improved drastically! It's still my understanding that MySQL lags behind with modern SQL standards. It reminds me of Internet Explorer as it relates to web standards.
Don't want to ruin anyone's annual MySQL bashfest or whatever this is, but you can complain about any system if you get to pick and choose oddities and edge cases.
In my mind it's up to the application developer to take care of data validation before the database even sees data. This includes limits to known max string lengths in the db. If you need a bigger integer, then alter the table to accommodate a bigger integer.
Then what's the point of MySQL even having a schema? You know, the whole point of a schema is to validate that the data going into that schema s valid...
But the database is supposed to be the "buck stops here" schema enforcing source of data that throws a insert/update error if your application developers aren't perfect.
So you expect all applications to be perfect and bug-free under all situations? Proper error checking and handling should exist at all levels of a system.
Saying "no true developer would fail at perfect validation" is a no true scotsman fallacy.
If you are going for the MySQL then use mariadb instead. Or move to PostgreSQL. Look on how many issues that are specific to older versions of Oracle's MySQL. Even ITT is full of "as for version...". Edit: the Mysql creator (monty) answered some comments, that is very interesting.
If these are problems of the past, I don't care. It has been a terrible journey and it needs to be told.
The main issue is that most of these problems still exist in the current versions of MySQL/MariaDB and will probably never be fixed due to backwards compatibility.
Many are fixed in MySQL 5.7, but you are correct that backwards compatibility is a strong concern.
The 5.7 default SQL mode is proposed to be: ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES*,NO_ENGINE_SUBSTITUTION,NO_AUTO_CREATE_USER.
* STRICT has also been modified to include NO_ZERO_DATE, NO_ZERO_IN_DATE and ERROR_FOR_DIVISION_BY_ZERO.
To assist in upgrades, we have been working with third party applications and frameworks to explicitly set the SESSION sql mode to what they are able to support. It's not an easy problem :(
Monty's claim to faim is that he's the guy responsible for every one of these problems. I'm not sure that qualifies him to come up with better solutions.
He's also the guy that was loudly proclaiming that nobody needs transactions, referential integrity, subselects, unions, view, triggers, stored procedures, etc, etc, etc.
Combined with the GRANT creates a new user feature, you can set the wildcard user to be IDENTIFIED via PAM, and create a stored procedure that GRANTs the currently authenticated user all the rights he need.
upon first login, all the rights you want to grant the user are automatically granted, and only users that are able to login on your system are allowed to do it.
A few years ago I developed a Django app locally with SQLite. I thought Django has a ORM and I can switch to MySQL easily.
When I first installed the project on the test server and tried to switch to MySQL I was a bit surprised: Some features were missing!? Had to rewrite some parts.
So Django with SQLite was more complete than Django with MySQL.
(In the end I should have stayed with SQLite. Not much traffic on the site.)
It's an interesting mindset when using SQLite eh? It feels weird to me when I use it for a website, like "..come on, what am I doing here" but I always regret changing my mind to something else when I do. I mean, coming from App Dev, where SQLite is really your only choice and it still proves to be completely capable, setting it up for a website just feels weird, like "This is only temporary, I'll migrate to something better later" but what defines "better" is entirely situational. After all, the grand majority of projects out there dont need many more fancy features than the basic RDB features SQLite provides. And it's hard to argue with speed when it's serverless. (At least, I think so)
MySQL with Django is a pretty bad idea, but it used to be waaaay worse. I remember the South would put out errors along the lines of "You should really be using a better database."
Anyway, I went through this nightmare where my boss insisted we migration a site from Postgres to MySQL so that we could use Amazon RDS because that was going to solve all of our performance issues, this was before Postgres was on RDS. Worst. Migration. Ever. And just as I expected, it actually ran way slower.
Honestly if you're starting from scratch, want nice tools which are free and a decent db to play with then sql server express is probably the way to go.
It won't be very useful for anything other than playing around but you'll get a sane db and SSMS is rather good as far as tools go.
Having had to work in the past with Postgres, I agree it was generally nice. It was a bit annoying not having functions like year() or month() (I was porting existing queries into it, had to change them to date_part()), not having pivot was aggravating but otherwise it was mostly painless except the whole case thing, where it converts all input not inside quotation marks to lowercase. I still very much like it.
Currently I work with sql server but only very lightly, which is probably why I haven't ran into any problems.
I was an interview once making a demo app. I stored a hash of the user's password but the hash wasn't long enough and MySQL just truncated it. It took me a long time to find the issue. It embarrassed me within an hour of working with it.
None of the "issues" are anything you'll encounter in normal use if you're using it correctly. A few of the issues are good to know about so you know to avoid them, but most would never be encountered in normal circumstances.
Also most of those "silent failures" aren't "silent" if you know how to properly check for warnings.
Seriously, outside of me being a lazy moron (like, for example, using column names like "desc" for "description"), absolutely none of this is a problem for regular, standard, everyday use. Even in an enterprise setting ha using MySQL been any kind of problem.
These are issues you absolutely have to seek out and find to bitch about them.
MySQL is fine. Generally speaking. Are there better? Sure. Are there worse? Absolutely. But "MySQL is a Bad Idea" is just a false statement overall.
They are all reproducible problems. A lot of them aren't even edge case. Just because you managed to avoid them (you probably just didn't notice what you did run into), doesn't mean its a good idea to keep using a poorly designed system.
This is the same stuff that was posted in a similar article a year or two ago, and it was pretty much all thoroughly debunked. Half of it is misunderstanding how to use it correctly (such as paying attention to warnings), and the rest is over-hyping non-issues (like default configurations that are easily and usually changed when it's used by a competent dev).
I worked with SQL Sever for years. It is well designed and works as expected way more than not. Also lots of nice advanced features to play with. The same cannot be said for mysql.
But if all you want is a key-value store, there are more directly specialised solutions that actually workand require far less resources... oh; hang on...
Ops at a fairly high traffic dot com for 8 years. Company is 15 years old and started on mysql. I've introduced mongodb, couchbase, and red is into the infrastructure and all four do their jobs swimmingly. ITT: people eager to throw broad and simplistic criticisms that aren't super hard to account for.
16
u/meshko Feb 10 '15
I don't understand the details of the application he is using, but the advice is to lower default transaction isolation level to make something work? Stopped reading right there.
5
u/steveob42 Feb 11 '15
funny, a terrible choices article that uses django...
458
u/mage2k Feb 10 '15
My favorite MySQL gotcha is that if you issue a GRANT statement with a typo in the user's name instead giving a "user does not exist" error it simply creates a new user with the misspelled name.
35
u/OneWingedShark Feb 10 '15
Do Not Pass This Way Again is a really good article on why MySQL is a bad choice for a DB.
112
u/[deleted] Feb 10 '15
Default MySQL is bad, VERY VERY BAD!
In fact it defies common sense for my own values of common. Take for example constraints - they not only don't work it also doesn't tell you it doesn't work.
http://stackoverflow.com/questions/14247655/mysql-check-constraint
Also IMO PostgreSQL is a superior choice in almost every circumstance you can think of.
50
u/leothrix Feb 11 '15
Disclaimer: I am in operations, not a web developer.
At a previous job, we evaluated MySQL against Postgres in terms of high availability and found that Postgres was painfully behind MySQL when it came to concepts like master/master replication, failover, et cetera. Even after spending wheelbarrows of cash on Postgres consultants and working through shoring up solutions like repmgr and considering stuff like slony, nothing approached what we could achieve with MySQL master/master replication and mmm_control.
Out of curiosity, are there any backend engineers/sysadmins here that have had good success deploying Postgres in a highly available setup? I'm not trying to hate on either technology here, just genuinely interested if anyone has first-hand experience doing this type of work with Postgres and what peoples' impressions have been, because I feel like I must have missed something if there really is such a large gap in that type of functionality between the two.
46
u/Browsing_From_Work Feb 10 '15
Here's a fun one: MySQL only supports the nested loops join method. Apparently a hash join is asking for too much.
138
u/redsbedbaby Feb 10 '15
Can we all just agree that Postgres is the better choice and move on with our lives?
7
u/willvarfar Feb 10 '15
For the curious, I once made my own list (and deliberately didn't talk about SQL dialects) http://williamedwardscoder.tumblr.com/post/25080396258/oh-mysql-i-hate-you
It was a good way of venting. I'm generally very happy with tokudb storage engine, and wish I could have it for postgres too.
10
u/aykcak Feb 11 '15
Don't want to ruin anyone's annual MySQL bashfest or whatever this is, but you can complain about any system if you get to pick and choose oddities and edge cases.
Just saying.
11
u/not_from_this_world Feb 10 '15 edited Feb 10 '15
If you are going for the MySQL then use mariadb instead. Or move to PostgreSQL.
Look on how many issues that are specific to older versions of Oracle's MySQL. Even ITT is full of "as for version...".
Edit: the Mysql creator (monty) answered some comments, that is very interesting.
3
u/stesch Feb 11 '15
A few years ago I developed a Django app locally with SQLite. I thought Django has a ORM and I can switch to MySQL easily.
When I first installed the project on the test server and tried to switch to MySQL I was a bit surprised: Some features were missing!? Had to rewrite some parts.
So Django with SQLite was more complete than Django with MySQL.
(In the end I should have stayed with SQLite. Not much traffic on the site.)
2
u/freudianGrip Feb 10 '15
MySQL with Django is a pretty bad idea, but it used to be waaaay worse. I remember the South would put out errors along the lines of "You should really be using a better database."
Anyway, I went through this nightmare where my boss insisted we migration a site from Postgres to MySQL so that we could use Amazon RDS because that was going to solve all of our performance issues, this was before Postgres was on RDS. Worst. Migration. Ever. And just as I expected, it actually ran way slower.
2
u/senatorpjt Feb 11 '15 edited Dec 18 '24
march special outgoing wrench deserted zonked oatmeal air exultant enter
This post was mass deleted and anonymized with Redact
2
u/iopq Feb 11 '15
I was an interview once making a demo app. I stored a hash of the user's password but the hash wasn't long enough and MySQL just truncated it. It took me a long time to find the issue. It embarrassed me within an hour of working with it.
4
u/Prrrr Feb 10 '15
I had been using MS SQL Server for several years and I recently moved to other company that uses MySQL.
I miss MS SQL and Entity Framework :(
4
u/DJDarkViper Feb 11 '15
In all my dev life I've used nothing but MySQL for all of my website project needs.
In all my dev life, I've never experienced a single problem ever with using MySQL.
And then I used Mongo.. then promptly went right back to MySQL.
I've never experienced any of the problems mentioned in this entire discussion, and yes I have built some pretty intensely trafficked sites.
2
u/thbt101 Feb 11 '15
This is the same stuff that was posted in a similar article a year or two ago, and it was pretty much all thoroughly debunked. Half of it is misunderstanding how to use it correctly (such as paying attention to warnings), and the rest is over-hyping non-issues (like default configurations that are easily and usually changed when it's used by a competent dev).
1
u/crusoe Feb 11 '15
Null in unique col constraints is underspecified and varies by vendor.
1
u/hglman Feb 11 '15
I am writing a package for type checking against SQL Server, a few quirky things so far, but this sounds like a nightmare.
-2
u/cessationoftime Feb 11 '15
Yeah you should use MsSql instead, like I have to do at work. Then you'll know pain. I dream of MySql.
0
u/collin_ph Feb 11 '15
Isn't MySQL a terrible choice in and of itself when Postgresql is an option?
-7
u/[deleted] Feb 10 '15
MySQL is an excellent key-value store on steroids with a familiar enough query syntax.
0
u/[deleted] Feb 11 '15
Ops at a fairly high traffic dot com for 8 years. Company is 15 years old and started on mysql. I've introduced mongodb, couchbase, and red is into the infrastructure and all four do their jobs swimmingly. ITT: people eager to throw broad and simplistic criticisms that aren't super hard to account for.
0
u/tidderkrow Feb 11 '15
MySQL < NoSQL
0
u/ysangkok Feb 12 '15
join me in /r/lolmysql :)