News for hackers. Stuff that matters.
Re:Why PostgreSQL is better than MySQL by wolph on Sunday October 15, 2017 @02:45PM (#15478523)
This post actually makes me wonder... is there anyone that objectively still thinks MySQL is the better database of the two?

The only small advantage of MySQL I can think of (which is a great downside as well) is that it's really tolerant towards all sorts of erroneous usage and data.

The following should be a problem but are accepted by MySQL

- missing group by clauses

- all of the `ignore` commands (insert, alter table, etc.) - incorrect dates

- not enforcing foreign key constraints

Re:Why PostgreSQL is better than MySQL by tyingq on Sunday October 15, 2017 @02:53PM (#15478580)
Uber switched from Postgres to MySql. https://eng.uber.com/mysql-migration/

If I remember right, though, mostly because their use pattern was more like a key value store, and MySQL worked better for that pattern.

Re:Why PostgreSQL is better than MySQL by wolph on Sunday October 15, 2017 @03:08PM (#15478685)
Thank you, very interesting read! They do raise a few good points where MySQL outperforms PostgreSQL. I suppose that's one of the trade offs between them, data safety vs. performance.
Re:Why PostgreSQL is better than MySQL by ris on Sunday October 15, 2017 @04:28PM (#15479130)
Re:Why PostgreSQL is better than MySQL by merb on Sunday October 15, 2017 @03:37PM (#15478868)
> Uber switched from Postgres to MySql.

really uber should not taken as an example, especially since they failed so hard with their databases in the past.

(I'm a Postgres fan, yes, but I think that there a valid reasons to migrate to MySQL (there are several other companies who use mysql, etc but Uber's stuff is just plain FUD))

Re:Why PostgreSQL is better than MySQL by h2so4 on Sunday October 15, 2017 @02:55PM (#15478592)
Are you sure mysql doesn't enforce foreign key constraints? I recently did a project with mysql backend and it did threw constraint errors on invalid inputs that didn't match a parent key record.
Re:Why PostgreSQL is better than MySQL by wolph on Sunday October 15, 2017 @02:57PM (#15478606)
You're partially correct. It does when inserting or updating, but if you do an alter ignore table you can create foreign key constraints that are actually invalid.

So... not in all cases

Re:Why PostgreSQL is better than MySQL by AlphaSite on Sunday October 15, 2017 @02:59PM (#15478625)
Doesn’t innodb atleast enforce those constraints?
Re:Why PostgreSQL is better than MySQL by wolph on Sunday October 15, 2017 @03:04PM (#15478665)
During most normal operations such as updates, inserts and deletes it will enforce them. But, opposed to other databases, you are allowed to completely ignore your foreign key constraints leaving you with a (in my opinion) possibly corrupt database.

  SET FOREIGN_KEY_CHECKS = 0;
  INSERT INTO ...
  SET FOREIGN_KEY_CHECKS = 1;
Now you might have data in your database that's actually incorrect.
Re:Why PostgreSQL is better than MySQL by shabble on Sunday October 15, 2017 @03:58PM (#15478975)
You can do this in postgres as well, with something like:

    begin; alter table t2 disable trigger all;
    insert into t2 (t1_id) values (20);
    alter table t2 enable trigger all;
    commit;
Setting constraints to deferrable/initially deferred[1] is probably a nicer way for any non-insane thing you're trying to achieve with such, though :)

[1] https://www.postgresql.org/docs/9.6/static/sql-set-constrain...

Re:Why PostgreSQL is better than MySQL by bmdavi3 on Sunday October 15, 2017 @04:04PM (#15479012)
PostgreSQL has the same feature actually, which I learned as part of a MySQL -> PostgreSQL migration that's underway.

    SET session_replication_role TO 'replica';
We need this to load the data in without worrying about table order, or even individual row order for foreign keys that reference their own table.

And we'll all try and forget this feature exists when we're done!