Postgres MySQL Bakeoff right tool for the right job when you have a hammer in your hand, everything looks like a nail
The contenders
SQL standard COMPLIANCE Postgres SQL92/99 (most of it) subqueries, views, multi-user support, transactions, query optimization, inheritance, and arrays. Mysql SQL92 (some of it) subqueries views (mysql5)
SQL NON-compliance Postgres Cannot query across multiple databases Mysql transactions inheritance arrays multiuser support query optimization
Table
Keys primary m & p foreign p m needs innodb multi primary keys
Data types Both: integer char, varchar, text Mysql only tinytext, mediumtext tinyint longtext, long blog Postgres only boolean timestamp
Sequences Postgresql yup Mysql what gives? cause of ire when writing code to run on both
Platforms Postgres Won't run on Windows9x/Me, NextStep, Ultrix. Mysql supposedly better on windows than pg.
Speed Postgres forks on every connection slower Optimization options Mysql choose the right table type connection time 10x faster than postgres
Stability Postgres once apon a time.. memory leaks and ick Now rock solid (7.4) Mysql unhappy with high connections per seconds (hundreds) Random disconnects and core dumps are exceptionally rare. proven in more high demand production environments than postgres
Data & Referential Integrity Postgres LOVES DATA INTEGRITY! transactions, rollbacks ON DELETE/UPATE, cascade Mysql basic CHECK clause allowed, but does nothing. InnoDB has foreign keys MySAM allows foreign keys, but they do nothing
Security Mysql GRANT + REVOKE username tablename hostname Postgres no grant/revoke for CREATE TABLE db access by host, ident, network segment
Locking and Concurrency Postgres MultiVersion Concurrency Control (MVCC) row level locks reader not blocked by writer Mysql Table locking for ISAM/MyISAM and HEAP tables InnoDB has row locking
Large Object Postgres needs lo_create then store by OID lo_read/lo_write Mysql just like other fields INSERT, UPDATE, SELECT and DELETE
Schema alterations Mysql Alter table (transaction gotcha) ADD, DROP, RENAME column CHANGE type Postgres ALTER TABLE, can be rolledback
Language support Neither handle multi char set databases Postgres compile with –enable-locale Mysql not many tasks use locale
Future Mysql adding views competing transaction support Postgres Improving performance speeds
Summary Data integrity important? use Postgres Speed, replication important, use well tuned mysql cheap hosting? mysql