News for hackers. Stuff that matters.
Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by DaiPlusPlus on Saturday February 27, 2021 @05:24AM (#26283888)
Define: "complicated"
Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by corty on Saturday February 27, 2021 @06:05AM (#26284041)
PostgreSQL: "your date 2020-02-31 isn't a date, fix that"

MySQL: "2020-02-31? Whatever man, I'll just enter something..."

Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by consp on Saturday February 27, 2021 @06:18AM (#26284101)
Considering the US uses a weird date format, I definitely prefer the former in combination with input sanitation forcing you to thing about your actions before assuming the database will fix it for you.
Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by corty on Saturday February 27, 2021 @06:32AM (#26284164)
Agreed. As with strong typing in programming languages, I do prefer a database to be strict in rejecting invalid inputs. MySQL does two bad things here: It accepts an invalid input plus it interprets it creatively, producing something the user most probably didn't intend. In that respect, MySQL is almost as bad as Excel creatively "interpreting" dates.

Another example of a database doing improper things would be Oracle mixing up the empty string with NULL. In Oracle, both are the same...

MySQL has a few more of those gotchas, e.g. regarding broken charsets (UTF-8 isn't 'utf8', it is 'utf8mb4', 'utf8' is an alias for 'utf8mb3' which is a broken subset). I wouldn't use MySQL for any data that was important to get back consistently. However, since Uber seems to be using some schemaless "we don't care"-layer anyways, that point is moot for the original article.

Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by vinger on Saturday February 27, 2021 @09:33AM (#26285072)
utf8mb3 isn't a broken subset. It includes characters in the basic multilingual plane which is fine for 99% of cases.

uft8mb4 uses more bytes than necessary for most. You get 255 varchar limits with uft8mb3, I think you only get 192 characters with uft8mb4.

Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by Alexendoo on Saturday February 27, 2021 @10:00AM (#26285240)
uft8mb4 does not use more bytes than utf8mb3, for anything representable by utf8mb3 the size in uft8mb4 is identical. Anything that would be 4 bytes in uft8mb4 is not able to be stored in utf8mb3

utf8mb3 is definitely a broken subset, it's deprecated at the very least

Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by bbarnett on Saturday February 27, 2021 @08:18AM (#26284661)
https://dev.mysql.com/doc/refman/8.0/en/sql-mode.html#sql-mo...

Much of your MySQL complaint is not a MySQL issue, but a config issue.

And yes, powerful config options are good, not bad.

Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by BitPirate on Saturday February 27, 2021 @09:55AM (#26285210)
One can still complain about mysqls dumb defaults.

https://dev.mysql.com/doc/refman/8.0/en/innodb-parameters.ht...

"Hey, let's just not act transactional on a timeout by default"

Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by evanelias on Saturday February 27, 2021 @10:54AM (#26285604)
That default is sensible. You're making it sound like this setting applies to all "timeouts" regardless of type. That is not the case.

This setting applies to lock-wait timeouts. The default value allows applications to decide on the correct course of action: either re-try just the statement that timed out (without having to re-do the previous parts of the transaction), or rollback the transaction.

The application still receives an error on the timeout regardless of this setting. The database doesn't automatically commit the previous statements in the transaction regardless of this setting.

Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by rubyist5eva on Saturday February 27, 2021 @09:45AM (#26285151)
The mysql behavior terrifies me because eventually you're going to end up with something you didn't expect and it's going to be a pain in the butt to track it down.
Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by evanelias on Saturday February 27, 2021 @10:51AM (#26285573)
MySQL's default settings reject invalid dates for over 5 years now, since MySQL 5.7.

How long are people going to keep repeating this complaint? Literally every version of MySQL and MariaDB that allows invalid dates by default (MySQL 5.6 and older, MariaDB 10.1 and older) has reached end-of-life for upstream support from the vendor!

Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by isoprophlex on Saturday February 27, 2021 @06:29AM (#26284156)
That doesn't exactly sell me on MySQL, sounds like a recipe for disaster
Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by corty on Saturday February 27, 2021 @06:34AM (#26284178)
There is more, however not everything is still valid or valid for every table type in MySQL: https://sql-info.de/mysql/gotchas.html
Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by evanelias on Saturday February 27, 2021 @11:08AM (#26285698)
"This page deals with issues related to MySQL 4.1 and earlier, not 5.0"

MySQL 5.0 came out over 15 years ago.

Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by chris_wot on Saturday February 27, 2021 @08:21AM (#26284680)
That's not decreasing complexity, that's just shifting it out of the database layer.

See https://news.ycombinator.com/item?id=26272084

Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by martimarkov on Saturday February 27, 2021 @07:32AM (#26284428)
Oh yeah old complication of sanitising input...

It’s like asking you for an int and you entering 2.358 and saying that’s just simple.

Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by exikyut on Saturday February 27, 2021 @10:23AM (#26285382)
Ooh, sounds like PHP 5!
Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by sschueller on Saturday February 27, 2021 @05:53AM (#26283992)
Recovering a split brain Galera cluster. Fun times...
Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by eznzt on Saturday February 27, 2021 @06:03AM (#26284027)
Just creating a new user is annoying enough.

Permissions are also much more complex.

What the hell are schemas?

Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by paulryanrogers on Saturday February 27, 2021 @08:56AM (#26284850)
Schemas are SQL standard namespaces within a DB. You can join between them. Mysql allows joining across databases, so it doesn't implement schemas.
Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by looperhacks on Saturday February 27, 2021 @07:04AM (#26284301)
How is creating a new user complicated? The normal CREATE USER is all I've ever needed to create a new user in postgres (assuming I don't have set up the pg_hba so that I need to allow every user separately)
Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by mgkimsal on Saturday February 27, 2021 @10:16AM (#26285325)
Most tutorials/instructions I read have you use "createuser" command from the system shell. But... you have to be able to switch to a system 'postgres' user first, which ... perhaps you don't have privileges to do, or need sudo access or whatnot.

If you can install postgres, connect to it directly with some sort of root identity, then immediately create users and databases (as is the case with pretty much every mysql walk-through I've ever seen), it's not a default.

https://wiki.postgresql.org/wiki/First_steps

"The default authentication mode is set to 'ident' which means a given Linux user xxx can only connect as the postgres user xxx."

This alone is a complicated/confusing thing, because it's mixing system accounts with the db server accounts/access - and none of that is obvious, and doesn't quite map to how other databases handle things. I've never had to have matching system account names for user access in MSSQL, for example.

Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by rleigh on Saturday February 27, 2021 @05:35PM (#26288796)
This depends entirely on how you want to set up and run the system. For packaged versions running as a system service with a dedicated service user, this is absolutely correct. And I would argue, it's a pretty sensible default arrangement.

But... there's absolutely nothing prohibiting you from running initdb as a regular user and then running the main daemon with your credentials. You are then the database owner and superuser. This type of thing is really useful for integration testing. But it's potentially useful when you don't care about the multiuser aspect and just want to have it run.

Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by chousuke on Saturday February 27, 2021 @10:59AM (#26285629)
With MySQL, you'll still have to switch to root to connect by default? I honestly don't remember, since it's been ages since I set up MySQL manually.

If MySQL actually allows administrative access out-of-the-box without any kind of special authorization, then that's a terribly insecure default.

With PostgreSQL, you have to switch to the superuser to configure things further because that's the only sane default you can have on an unconfigured system. If you can run commands as the user PostgreSQL is running as, you are "safe" to trust, and PostgreSQL will let you in.

UNIX ident authentication is also is extremely convenient for local applications, since you don't even have to have a password for the account, or make the PostgreSQL server network-accessible in any way.

Oracle can do the same thing, and so can MySQL, apparently (with IDENTIFIED VIA unix_socket).

MySQL user management has its own complexity in that you have to manage "user@address" identities, and the same user at different addresses or auth methods can have different permissions. How's that "simple"? With PostgreSQL, your users will at least map to the same user regardless of how they authenticate themselves.

Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by mgkimsal on Saturday February 27, 2021 @12:54PM (#26286628)
"With MySQL, you'll still have to switch to root to connect by default? "

You connect with a root account from any account, and when installed, the root account password is part of the setup process.

"and the same user at different addresses or auth methods can have different permissions"....

It joe@localhost and joe@remotehost don't have to be 'the same user' in that they're not tied to a system account in any way.

Granting different privileges to joe@local and joe@remote based on where they're coming from isn't necessarily "simple", but no one claimed it was. My own response was validating that PostgreSQL user setup was somewhat confusing.

EDIT: Bringing up "mysql sucks" points when I was explaining how PostgreSQL 'create user' stuff can be confusing just reeks of whataboutism.

Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by chousuke on Saturday February 27, 2021 @01:09PM (#26286750)
I'm just not sure how it's confusing? PostgreSQL users aren't "tied" to system accounts either. You can have any number of PostgreSQL users that have no system equivalent.

In fact, the process seems to be exactly the same as with MySQL: I just tried installing the MariaDB server (dnf install mariadb-server), and it didn't prompt me for an admin user; instead, I can directly connect to the database as root using sudo, so in this case it appears to be doing the exact same thing that PostgreSQL does.

It just happens to be that by default the "postgres" superuser has a corresponding "postgres" system user that can log in via OS authentication, so you need to switch to the postgres user instead of root.

EDIT: Maybe some of the confusion stems from the fact that the documentation you linked seems to assume that the database is created according to convention to run as the "postgres" user (as it usually is). If your user didn't have the required permission to switch to the postgres user, they wouldn't be able to install the database as said user in the first place.

If you install PostgreSQL as your own user (which is not a good idea if you have any other option), you will not need to switch users as you will obviously have access to the database files and can do whatever you want, anyway.

Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by mgkimsal on Sunday February 28, 2021 @09:07AM (#26293499)
"Maybe some of the confusion stems from the fact that the documentation you linked seems to assume that the database is created according to convention to run as the "postgres" user (as it usually is)".

The entire point was a reply to someone saying "it's confusing". I'm pointing out how it's confusing, and you come back with that either that 1) MySQL is confusing or 2) you don't think it's confusing. Then you point to documentation which you admit might be a point of confusion.

I've had people say "I installed postgres - here's the password". Then... I can't log in. Because I can't switch to the postgres user. Or they created some login that I can't use. Or something else... because it's somewhat confusing, unless you do this (postgres administration) as part of your regular/periodic work.

re: "I just installed Maria"... If someone uses common default package managers to set up mysql/Maria, and also for postgres, you'll be able to connect to mysql/Maria from any account. You'll only be able to connect to postgres if you switch to the postgres user.

Again - point of the comment was agreeing with an earlier comment that "this is confusing". You seem to acknowledge that it can be confusing.

Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by chousuke on Sunday February 28, 2021 @03:04PM (#26296537)
> I've had people say "I installed postgres - here's the password". Then... I can't log in. Because I can't switch to the postgres user.

You don't need to switch to the postgres user if you have another database user and password.

Are you talking about a situation where someone has installed a PostgreSQL server but hasn't configured PostgreSQL to allow password authentication? The server admin needs to allow that explicitly, because some distributions don't allow password authentication even on localhost by default, but honestly, it's all very well documented.

> If someone uses common default package managers to set up mysql/Maria, and also for postgres, you'll be able to connect to mysql/Maria from any account.

This is not the case on Fedora at least, since fresh out of the package the MySQL root user has no password; the only way to connect is via local system authentication as the root user.

Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by vinger on Saturday February 27, 2021 @09:41AM (#26285126)
Does postgres still require a separate user to access the db.

I remember this being a limitation in 2008.

That forced user creation always pushed me to mysql because I hate having separate users for each service because you still have to manage and account for these extra accounts.

Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by oftenwrong on Saturday February 27, 2021 @06:32AM (#26284172)
Schemas are similar to databases in mysql. They serve as a namespace. In mysql you can have a database `foo` and a table `foo.bar`. In postgres you can have a schema `foo` and a table `foo.bar`. In postgres you can have multiple databases in a cluster, and multiple schemas within each of those databases.
Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by eznzt on Saturday February 27, 2021 @07:11AM (#26284333)
What you are basically saying is that yes, they are much more complex.
Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by rleigh on Saturday February 27, 2021 @07:40AM (#26284480)
They are not complex, and they are entirely optional. They are just a namespace. You are free to never, ever use them.

For a company the size of Uber, I don't think spending five minutes reading the documentation for createuser is a significant burden to deployment. PostgreSQL is very easy to deploy.

Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by desas on Saturday February 27, 2021 @07:23AM (#26284392)
It's another layer, you don't have to use it. If you pretend schemas don't exist you basically never know they do, unless you go looking for complexity in the postgres bowels.
Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by Tostino on Saturday February 27, 2021 @08:04AM (#26284610)
To be honest, it's better to think of MySQL db = Postgres schema, because I'm MySQL you can do cross db queries and there is no intermediary schema level, and in Postgres you can do cross schema queries, but not cross db queries.
Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by chris_wot on Saturday February 27, 2021 @08:23AM (#26284692)
No, what you mistake for "complexity" seems to be your general unfamiliarity of what a schema is. In fact, when you understand what schemas are, then it actually makes a lot more sense.
Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by lucian1900 on Saturday February 27, 2021 @09:50AM (#26285184)
What MySQL calls databases are actually schemas. They’re even aliases as such.

MySQL doesn’t have multiple SQL databases, you’ve been using multiple schemas.

Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by isoprophlex on Saturday February 27, 2021 @02:25PM (#26287394)
"What the hell is scoping? Why not put every variable in global scope? Much less complex"
Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by tinus_hn on Saturday February 27, 2021 @07:13AM (#26284340)
It would be great if there was some management GUI for these tasks so you don’t have to look up the syntax for these things that in many deployments you only do once.
Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by rektide on Saturday February 27, 2021 @01:44PM (#26287037)
both kubernetes operators have some ok user management built in
Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by mvanbaak on Saturday February 27, 2021 @08:23AM (#26284690)
pgadmin ;-P
Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by tinus_hn on Saturday February 27, 2021 @09:50AM (#26285181)
This actually looks pretty reasonable, I am going to look into it. First I need to figure out how to open up the server for connections but still limit it, though.
Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by jhauris on Saturday February 27, 2021 @10:20AM (#26285364)
Look at the pg_hba.conf file (probably something like /etc/postgresql/<version>/main/pg_hba.conf).

https://www.postgresql.org/docs/current/auth-pg-hba-conf.htm...

Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by tinus_hn on Saturday February 27, 2021 @05:39PM (#26288826)
Perhaps it’s better to only listen to localhost and connect through a SSH proxy connection
Re:Why Uber Engineering Switched from Postgres to MySQL (2016) by rleigh on Saturday February 27, 2021 @05:36PM (#26288802)
Or DataGrip if you already have a JetBrains licence.