Making MySQL Better at GitHub
github.com
github.com
Interestingly, I would love to see companies like Github opening up their database schemas to the public with mock data. Scaling is one aspect, but the best thing you can do in the beginning is to create a solid schema (normalise, denormalise...) it would be interesting to see what Github uses and why. Still awesome to see MySQL being the choice most large companies like Github choose in the face of new and untested NoSQL databases like MongoDB.
Honestly, is there any reason to use MySQL over Postgres at this point? Or is it sort of six of one half a dozen of the other as long as the data model is decent?
So yeah, Postgres is a better relational database than MySQL, if you ignore all the things MySQL does better. Another great thing about Postgres is that whenever a site like Hacker News gets a thread about MySQL, you get a bunch of people asking why you aren't using Postgres instead, and then whenever you try and answer the question you get a bunch of Postgres users to tell you you're wrong or that the features you care about don't matter (or that they're hard to implement, which... this is my problem why?) or that Postgres really has replication that's as good as MySQL's this time we pinky swear. So most MySQL users get a first impression of Postgres' user community that is quite frankly rather unfavorable.
Oh, and MySQL has a lot more third-party documentation, tooling and support available.
But the idea that MariaDB is "upstream" of Oracle MySQL is silly. Is Oracle even merging code from MariaDB?
I'm no DBA, but I'd think Monty (the creator of MySQL) and his smaller crew at his consulting firm (SkySQL and MariaDB Consulting) which makes MariaDB would be more open and flexible to working directly with Github's teams and needs than through the bureaucracy at Oracle.
https://mariadb.com/blog/mysql-56-vs-mariadb-100
So if you need, for instance, MySQL 5.6's partitioning improvements:
https://blogs.oracle.com/MySQL/entry/mysql_5_6_is_a
You're better off on Oracle MySQL. There's other tradeoffs, depending on what you use. What bugs the heck out of me is how a fair number of MariaDB advocates spread FUD about Oracle (if you judge them by their track record, they've committed to improving and maintaining MySQL -- they're not perfect, but that's no excuse to harp about stuff they COULD do when there's no evidence they WANT to sabotage MySQL to force you to switch to Oracle), and want to turn the debate into a holy war rather than focusing on letting everyone pick the best tool for the task.
> You're better off on Oracle MySQL.
Hardly true, given the two db's are mostly the same except that the creator is now making newer and better changes in the 10.x branch of MariaDB (Monty left Oracle just like most Sun employees due to inner-politics and fighting that is regular at Oracle).
In general MySQL is a lot more widely used with a greater pool of knowledge out there.
As an example, the organization I work at is considering a move to psql, but our main barrier is a lack of good DB clients that are accessible to people who aren't software developers. The best we're aware of as far as DB GUIs for Postgres is pgAdmin, whereas if we're talking MySQL you have things like MySQL workbench, SQLPro, and a myriad of other applications available for whatever your operating system of choice is.
Eg disabling connections per database using sql and having built-in query stats (http://www.postgresql.org/docs/9.4/static/pgstatstatements.h...) just made me smile.
5.7 is going to be amazing for observability. Memory, transactions, stored procedures, replication, meta data locking and prepared statements are all instrumented in P_S.
Yes, I really wish DHH and the Basecamp team would move to Postgre , therefore moving the community to it.
In October 2013, NewRelic reported that 53% of their customers are using PostgreSQL: http://blog.newrelic.com/2013/10/10/infographic-state-stack-...
In July 2014, Planet Argon's Rails survey showed a surge in preference for PostgreSQL since 2012: http://rails-hosting.com/Results/2014/index.html#Database
Neither captures the distribution of usage from small- to large-scale apps, but it does look like the community has already moved both in mindshare and number of production deployments. I'd wager that Heroku's PostgreSQL default is responsible for much of that.
If you're picking up a framework, do you use the default database or try to do something non-default on top of what you're already learning?
Really? Defaults are supposed to be sane and the best-fit-for-most-common-scenarios... so it's a little patronizing to automatically assume your project is just so special that defaults are not good enough.
Defaults should be good enough until they have been proven to not be good enough. Don't over-engineer your project.
Most of the time MySQL optimization is workload specific.
It shows how little you know about real world scalability when you actually suggest MySQL over something like Cassandra. It is a nightmare to scale unless you are sharding in your application layer.
MongoDB is new and untested? What rock do you live under?
It is new compared to many of the veteran Relational databases like SQL Server (and I don't mean that in a bad way), but it is a proven technology used by many. See http://www.mongodb.com/who-uses-mongodb
Mongodb is a good db but it is not good for many use cases that people are using them for. There are a lot of companies that realized the mistake and are actively migrating off it. I know we are planning a "Off-Mongo party" with another company once we both manage to migrate off
Many of us who used MongoDB have concluded that there is no task at which it is in any way better than all other existing alternatives.
At my company most of our systems are SQL Server powered, but one of the newer systems that stores large blobs of metadata for products is using Mongo, and it is working quite well.
Many of the companies that switched off MongoDB were growing and ended up moving up to databases like Cassandra. MongoDB is a great database from when you're starting to when you're mid sized.
Cassandra destroys PostgreSQL in scalability but we don't say PostgreSQL is a crap database because of it.
thread_handling=pool-of-threads
http://www.percona.com/doc/percona-server/5.5/performance/th...> Note This feature implementation is considered BETA quality.
The queries on my db server, fit the documented use case for this feature - lots of short live queries.
It doesn't make sense for all workloads, but I have found thread pool to be useful in cases where application servers can overload database servers (either via misconfigured connection pooling, or no pooling).
An example where it might make less sense: a dedicated worker queue running in N threads connecting to MySQL.
https://mariadb.com/kb/en/mariadb/mariadb-vs-mysql-compatibi...
When I ran the tests for MariaDB 10.x and MySQL CE 5.6.x the advantage even went further for MySQL with around 20% better performance.
I find always funny how with every release you can get opposing claims from each camp regarding performance.
I'm sure one day MariaDB will replace stock MySQL but clearly it's not ready yet.
btw Oracle is doing a good job with MySQL atm.
One concrete example is hashjoins, a fairly simple and efficient strategy for many general purpose workloads: MariaDB supports hashing as a join strategy since 5.3/5.5 [1] back in 2011. MySQL, to the best of my knowledge, still lacks any implementation of this. OracleDB, of course, supports hash joins. Oracle has every incentive not to implement hash joins in MySQL because hash joins are one of the performance features that they use to drive sales of OracleDB.
[1] https://mariadb.com/kb/en/mariadb/what-is-mariadb-53/#join-o...
Obvious troll is obvious.
> the performance is BS
We're extremely happy with our "BS" performance.
MySQL professional here. I'm quite pleased with Oracle's 5.5 and 5.6 releases, and feel that they're doing a pretty good job. While they've not been perfect stewards, I feel they have done better than Sun -- perhaps you don't remember the fiasco that was the 5.1 release?
I don't feel that this is a trollish opinion. Mark Callaghan, a MySQL luminary who has done a lot of excellent work for the community also has positive things[0] to say about Oracle's stewardship of MySQL.
Actually yes, it is. It doesn't work the other way around (for example timestamp column has a different description, so dump cannot be loaded into MySQL). But you can use MariaDB in place of MySQL and there should be no performance degradation, since they come from the same codebase.
Reliability was mentioned too - in that case Oracle actually failed by holding back tests. In MariaDB you can reproduce testing if you want. In MySQL not anymore.
MariaDB is also impacted by the lack of tests, they are absolutely not making replacements for all those tests, and they continue to pull code from upstream. So, same problem there.
The fact that they continue to "pull" some code is because they're not idiots, and aren't going to duplicate effort. As far as I'm aware, they are now being very selective about what they pull.
Calling Oracle an "upstream" is a joke. They aren't publishing atomic changesets, which also means the Oracle fork of MySQL is no longer a morally Open Source software program.
MariaDB is NOT impacted by some vaporous lack of tests. They are building tests for every change they're making. As for the tests privately held by Oracle, well, those tests don't help anyone because they're not public and don't enjoy public scrutiny. Who knows if they're even running them?
They have received large investments from companies like Intel, and have been granted extensive engineering (and probably financial) help from companies like Google and Facebook. Probably many others. And they have most of the MySQL brains-trust in their employ, Monty most famously. I don't know how anyone could argue they're under-resourced for the task of maintaining and improving a mature product.
Compare that with Oracle, who pulls dangerous stunts like this: http://ronaldbradford.com/blog/when-is-a-crashing-mysql-bug-...
You mean Jeremy Cole, the guy you're arguing with, who led the effort at Google to standardize on MariaDB[0], who worked for many years with Monty at MySQL AB and who is a recognized leader in the MySQL community?[1] Fuck that guy, I have no idea how he could have such an opinion.
[0]: http://www.theregister.co.uk/2013/09/12/google_mariadb_mysql...
[1]: http://openlife.cc/blogs/2013/april/mysql-community-awards-2...
I know for a fact that if we were forced away from MariaDB back to stock Oracle MySQL releases, we'd have to expand onto more slaves and fix queries that are no longer optimized.
We've also migrated many tables to TokuDB storage engine, and seen phenomenal improvements in performance and scaling. It's so good we were able to de-partition and de-archive our largest tables with no performance penalty.
If you haven't tried MariaDB yet, try it.
If your database is reasonably large (10GB+) and you haven't tried TokuDB yet, TRY IT.
Server - Ubuntu 14.0.4 Mysql - Percona XtraDB Cluster 5.6 RAM - 16 GB CPU - 8 Cores - 2.95 Ghz SSD - 100 GB
I tried many options --
1) Increased the innodb_buffer_pool_size to 8GB on a 16GB RAM machine -- It helped but nothing magical here 2) Add few more Keys on Date based columns and force the users in front end to select at least one date range column -- Seen some performance gain here 3) Tried MyISAM engine -- I would say in present days MyISAM is history since Innodb itself is pretty much comparable to MyISAM -- so didn't see amy much performance gain .. one disadvantage was that loading of this 12 Million rows took ages .. and also "SELECT table_rows FROM information_schema.tables" had hanged , so i was not able to to figure out that how many rows have been loaded in my Table. 4) Finally I tried Partitioning the Table based on a DATE column -- Massive Performance gain .. If the user has selected a date range which falls under one or two partitions , then you can get the results very fast , even if it falls in many partitions still the performance is acceptable .. Useful ref - http://www.slideshare.net/datacharmer/mysql-partitions-tutor... -- remember that its Mandatory that you add that date column as part of Primary Key if you are Partitioning on that date column .
--- For Ref -- my Innodb settings
# INNODB # innodb-flush-method = O_DIRECT innodb-log-files-in-group = 2 innodb-log-file-size = 512M innodb-flush-log-at-trx-commit = 2 innodb-file-per-table = 1 innodb-buffer-pool-size = 6G bulk-insert-buffer-size = 256M innodb_thread_concurrency = 16
Table size 10GB and rows 12 Million
Also note that I am using the default settings of Tokudb
With Tokudb - 1 min 41.38 sec With Innodb - 58.17 sec
So almost double.
Inertia explains the current MySQL position reasonably well, a better question is how did it climb to its current position during its years of technical incompetence.
Existing, and having an better install story and windows support than PostgreSQL. When it established its dominance, it wasn't because it was the best open-source multi-user relational database in terms of spec sheet features, it was because it was the one people trying to start something could easily setup and get something running with, which quickly led to it being widely supported on shared hosts and having a large base of people with at least some experience, which then created a nice positive feedback loop to maintain its popularity.
As for "how did it climb" the answer is simple: replication. Working replication was available in MySQL years ago too. Not perfect, but working.
Big companies usually do have competent people who make informed decisions, not based "I've read on the internet that PG is the real DB and MySQL is just a toy".
There's been a perception for a long time that MySQL was "more lightweight" than traditional RDBMS's and therefore "faster", the same thinking that perpetuates NoSQL solutions today.
Originally Postgres didn't even support SQL. mSQL was developed as an SQL interface to Postgres in the mid 90s. When it turned out Postgres was dog slow on the old-ass hardware the devs were using they just implemented their own lightweight db and mSQL became the top pick for new OSS-based systems. But mSQL was commercially licensed, so MySQL was created for personal use. Since it reused the same API as mSQL, everyone just adopted MySQL as a 'drop-in' replacement. So MySQL is lightweight and fast and free and Postgres is a dog slow incumbent.
I guess you could compare it to how many people feel Java is a humongous pig that can't scale and PHP is fast and lightweight. And obviously lots of sites use PHP. But some shops choose Java because they want something PHP can't offer. (Note: this is not a fair comparison to MySQL and Postgres in any way, but it shows the weird 'feelings' people get for different software)
But also: MySQL has more DBAs, a higher number of installations, more 3rd party support, bigger user/dev community, and in general is more popular.
> technically, is MySQL less capable than Postgres?
Each has individual technical benefits and drawbacks the other doesn't have.
> Would it be wrong to start a new business on MySQL?
What, like, ethically?
MySQL is just a tool. I could 'bash' a table knife by saying it's a dull, heavy piece of shit compared to some other knife, but guess what? Everyone uses table knives. They don't typically use them to debone fish, however. Look at your use case and pick the tool you feel comfortable with that fits it best.
Even though it is not without its faults it is a reliable and high performing database, which is what is needed at scale.
> is MySQL less capable than Postgres?
Definitely not.
Have you used both professionally? Not being arsey, seriously interested.
Git data gets stored with Git on separate file servers.
Any further details on the DB servers, SSDs that were used, and the 10Gb networking infrastructure?
http://dev.mysql.com/doc/refman/5.6/en/innodb-undo-tablespac...
Because in mysql, ibdata1 can never shrink, only grow.
And that's how you end up with massive ibdata1 files that cannot be managed.
Oh and undo can only be moved outside of ibdata when mysql is being initialized, not afterwards.
innodb has some serious flaws
http://www.percona.com/blog/wp-content/uploads/2010/04/InnoD...
Users cannot drop the separate tablespaces created to hold InnoDB undo logs, or the individual segments inside those tablespaces.
The most important part to control ibdata1 growth is innodb_file_per_table (default now).
The rest of ibdata1 has to be cached for performance.
Impossible to isolate the caching needs unless undo is moved outside and 99% of servers out there have probably not been setup with external undo logs because most admin do not know of this limitation after it has been configured.
Only way around this is to rebuild the entire database, loads of fun.
Also usually you are on call every so-often so if your team/company happens to do this often it's not always you performing the deployment.
In regards to "being in the office": most people will do this from home after sleeping most of the night and waking up to an alarm and then coming in a little later the next day. There are a few hardcore ones out there that prefer to pull an all-nighter and do so from the office, although my mileage has been those are quite few and far between.
If something goes wrong with your database, you'll be in a shitty condition to make fast and sound judgement calls.
One could say that not everybody's the same, but in those conditions I think that's not true. I've trained extensively under sleep deprived conditions in the military, where we were continually asked to make quick decisions in harsh conditions. Everybody's bad when sleep deprived and everybody's especially shitty at 5AM.
DevOps/Admin here! I prefer the all-nighter, but I've almost always (in 14 hours) done it from home unless physical hardware had to be moved (i.e. forklifted datacenter to datacenter).
That sort of thing should be the extreme exception--anything else is just burning out employees.
By the way, one full time equivalent (that is, a hypothetical person working 24 hours a day all year long) equalled to five real people. That is, if they wanted ten people to be always available they had to hire fifty. You can easily understand why these arrangements are not common for Internet companies. Furthermore telcos have different requirements. Devops wasn't there yet and I wonder if it is accepted by management even now. My bets are against it.
I also wonder if companies like Google, Amazon and Facebook are organized in that way too.
I do snapshots + binlogs so I can do a point-in-time recovery to any time in the last month. So obviously a delayed replica would be a faster way to recover from human error at the MySQL prompt. But it would still require human intervention which is slow and can't really be automated. On the other hand, presumably a process already exists to bring a replica up from scratch, and that could be done and paused at a certain point. So it seems like a lot of extra effort and hardware for a really narrow and constrained benefit.
Anyone running a delayed replica -- is this wrong? Has it been used ever? often? Worth it?
You are correct in that the main use-case is fast recovery from human error. But as a DBA, I can tell you that accidents like this cover 90% of disasters :)
If we make a change and want to quickly compare against an older version of the data delayed slaves are super handy.
We can also restore to any point in time with binlogs.
I feel 13 minutes of maintenance at 5am PST was a good trade off for the benefits we gained.
There are three factors here for me:
I automate things if it will save me time. I automate things if it will provide necessary reliability to the process. I automate some things which annoy me to do manually, even if I can't justify it on either of those basis.
The second one is tricky. When things go pear shaped in new and interesting ways 10 points into your automatic scripts, do they correctly and automatically recover? Mine generally don't. I'm going to react better to things going pear shaped.
But my coworkers don't necessarily have the same attention to detail with my checklist. This can be because they're not as familiar with the tools, or simply don't believe the rigor justified, or necessary.
Personally, I've always been wowed at what youtube does with mysql. See the entire vitess[1] project for an idea. Thanks github for writing this up though, very neat.
No one would argue that MySQL's database engines can't scale. But you could argue that the relational model doesn't scale.
I often see "MySQL doesn't scale" posts which simply isn't true. I just wish people would stick with it longer and iron out their problems.
How would one make such an argument? The relational model is simply a combination of logic and set theory used for manipulating data. It's orthogonal to scalability concerns.
These are important distinctions, because a misconception here leads to entirely the wrong solution.
One thing that does have inherent physical constraints is consistency. That's usually what people mean when they say that the relational model doesn't scale, but it would be much less confusing to just say that. Then there would be no reason to dismiss a relational language when designing scalable systems.
10 years ago 1T would be "big data" whereas today, 1P would be "big data". I'm waiting for the time when you can get 1P ssd drives for your laptops :)
Deleted comment
Generally the use case for "scale" with NoSQL isn't that MySQL isn't technically capable. It is a cost/benefit for a specific use case.
For instance, if you are storing counters that are purely tracked via key/value ... MySQL is a terrible choice from a server-cost-to-performance-perspective.